You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
* Fix Checkstyle violations in this module
* Make all the Twitter function auto-configurations as conditional on their specific properties
to avoid extra beans not expected in the target application
* Fix README respectively
Copy file name to clipboardExpand all lines: function/spring-twitter-function/README.adoc
+18-28Lines changed: 18 additions & 28 deletions
Original file line number
Diff line number
Diff line change
@@ -2,34 +2,31 @@
2
2
3
3
This module provides couple of twitter functions that can be reused and composed in other applications.
4
4
5
-
To use those functions add the following dependency to your POM:
5
+
This module exposes auto-configurations for the following beans:
6
6
7
-
[source,XML]
8
-
----
9
-
<dependency>
10
-
<groupId>org.springframework.cloud.fn</groupId>
11
-
<artifactId>twitter-function</artifactId>
12
-
<version>${java-functions.version}</version>
13
-
</dependency>
14
-
----
7
+
* `twitterTrendFunction`
8
+
* `twitterUsersFunction`
9
+
* `twitterGeoFunction`
10
+
11
+
Each of them are conditional by specific configuration properties.
15
12
16
13
## 1. Twitter Trend Function
17
14
18
-
Functions can return either Trends topics or the Locations of the trending topics. The `twitter.trend.trend-query-type` property allows choosing between both types.
15
+
Function can return either Trends topics or the Locations of the trending topics.
16
+
The `twitter.trend.trend-query-type` property allows choosing between both types.
17
+
This property is required to enable the function auto-configuration.
19
18
20
-
* Trends - `twitter.trend.trend-query-type` is set to `trend`. Leverages the https://developer.twitter.com/en/docs/trends/trends-for-location/api-reference/get-trends-place[Trends API] to return the https://help.twitter.com/en/using-twitter/twitter-trending-faqs[trending topics] near a specific latitude, longitude location.
19
+
* Trends - `twitter.trend.trend-query-type` is set to `trend`.
20
+
Leverages the https://developer.twitter.com/en/docs/trends/trends-for-location/api-reference/get-trends-place[Trends API] to return the https://help.twitter.com/en/using-twitter/twitter-trending-faqs[trending topics] near a specific latitude, longitude location.
21
21
22
-
* Trend Locations - the `twitter.trend.trend-query-type` is set `trendLocation`. Retrieve a full or nearby locations list of trending topics by location. If the `latitude`, `longitude` parameters are NOT provided the processor performs the https://developer.twitter.com/en/docs/trends/locations-with-trending-topics/api-reference/get-trends-available[Trends Available API] and returns the locations that Twitter has trending topic information for.
22
+
* Trend Locations - the `twitter.trend.trend-query-type` is set `trendLocation`.
23
+
Retrieve a full or nearby locations list of trending topics by location. If the `latitude`, `longitude` parameters are NOT provided the processor performs the https://developer.twitter.com/en/docs/trends/locations-with-trending-topics/api-reference/get-trends-available[Trends Available API] and returns the locations that Twitter has trending topic information for.
23
24
If the `latitude`, `longitude` parameters are provided the processor performs the https://developer.twitter.com/en/docs/trends/locations-with-trending-topics/api-reference/get-trends-closest[Trends Closest API] and returns the locations that Twitter has trending topic information for, closest to a specified location.
24
25
25
26
Response is an array of `locations` that encode the location's WOEID and some other human-readable information such as a canonical name and country the location belongs in.
26
27
27
28
### 1.1 Beans for injection
28
29
29
-
You can import the `TwitterTrendFunctionConfiguration` in a Spring Boot application and then inject the following bean.
30
-
31
-
`filterFunction`
32
-
33
30
You can use `Function<Message<?>, Message<byte[]>> twitterTrendFunction` as a qualifier when injecting.
34
31
35
32
Once injected, you can use the `apply` method of the `Function` to invoke it and get the result.
@@ -45,12 +42,11 @@ See this link:src/test/java/org/springframework/cloud/fn/twitter/trend/TwitterTr
45
42
46
43
### 1.4 Other usage
47
44
48
-
Leveraging the Spring Cloud Function composability, you can compose the Trend function in your boot app like this:
45
+
Leveraging the Spring Cloud Function "composability", you can compose the Trend function in your boot app like this:
49
46
50
47
[source,Java]
51
48
----
52
49
@SpringBootApplication
53
-
@Import(TwitterTrendFunctionConfiguration.class )
54
50
public class MyTwitterTrendBootApp {
55
51
56
52
public static void main(String[] args) {
@@ -79,11 +75,9 @@ Some parameters in this method are only required based on the existence of other
You can import the `TwitterGeoFunctionConfiguration` in a Spring Boot application and then inject the following bean.
78
+
This function auto-configuration is conditional on `twitter.geo.search.ip != null || (twitter.geo.location.lat != null && twitter.geo.location.lon != null)`
85
79
86
-
`filterFunction`
80
+
### 2.1 Beans for injection
87
81
88
82
You can use `Function<Message<?>, Message<byte[]>> twitterGeoFunction` as a qualifier when injecting.
89
83
Once injected, you can use the `apply` method of the `Function` to invoke it and get the result.
@@ -96,7 +90,7 @@ For more information on the various options available, please see link:../twitte
96
90
97
91
### 2.3 Tests
98
92
99
-
See this link:src/test/java/org/springframework/cloud/fn/twitter/geo/TwitterGeoFunctionTest.java[test suite] for examples of how this function is used.
93
+
See this link:src/test/java/org/springframework/cloud/fn/twitter/geo/TwitterGeoFunctionTests.java[test suite] for examples of how this function is used.
100
94
101
95
### 2.4 Other usage
102
96
@@ -105,7 +99,6 @@ Leveraging the Spring Cloud Function composability, you can compose the Geo func
105
99
[source,Java]
106
100
----
107
101
@SpringBootApplication
108
-
@Import(TwitterGeoFunctionConfiguration.class )
109
102
public class MyTwitterGeoProcessorBootApp {
110
103
111
104
public static void main(String[] args) {
@@ -122,17 +115,14 @@ Uses SpEL expressions to compute the query parameters from the input message.
122
115
Use the single quoted literals to set static values (e.g. user-id: '6666, 9999, 10000').
123
116
124
117
Use `twitter.users.type` property allow to select the query approaches.
118
+
This property is required to trigger the `twitterUsersFunction` auto-configuration.
125
119
126
120
* https://developer.twitter.com/en/docs/accounts-and-users/follow-search-get-users/api-reference/get-users-lookup[Users Lookup API] - Returns fully-hydrated user objects for up to 100 users per request, as specified by comma-separated values passed to the `userId` and/or `screenName` parameters. Rate limits: (300 requests / 15-min window)
127
121
* https://developer.twitter.com/en/docs/accounts-and-users/follow-search-get-users/api-reference/get-users-search[Users Search API] - Relevance-based search interface to public user accounts on Twitter.
128
122
Querying by topical interest, full name, company name, location, or other criteria. Exact match searches are not supported. Only the first 1,000 matching results are available. Rate limits:(900 requests / 15-min window)
129
123
130
124
### 3.1 Beans for injection
131
125
132
-
You can import the `TwitterUsersFunctionConfiguration` in a Spring Boot application and then inject the following bean.
133
-
134
-
`filterFunction`
135
-
136
126
You can use `Function<Message<?>, Message<byte[]>> twitterUsersFunction` as a qualifier when injecting.
137
127
Once injected, you can use the `apply` method of the `Function` to invoke it and get the result.
Copy file name to clipboardExpand all lines: function/spring-twitter-function/src/main/java/org/springframework/cloud/fn/twitter/geo/TwitterGeoFunctionConfiguration.java
+16-14Lines changed: 16 additions & 14 deletions
Original file line number
Diff line number
Diff line change
@@ -1,5 +1,5 @@
1
1
/*
2
-
* Copyright 2020-2020 the original author or authors.
2
+
* Copyright 2020-2024 the original author or authors.
3
3
*
4
4
* Licensed under the Apache License, Version 2.0 (the "License");
5
5
* you may not use this file except in compliance with the License.
Copy file name to clipboardExpand all lines: function/spring-twitter-function/src/main/java/org/springframework/cloud/fn/twitter/geo/TwitterGeoFunctionProperties.java
+16-21Lines changed: 16 additions & 21 deletions
Original file line number
Diff line number
Diff line change
@@ -1,5 +1,5 @@
1
1
/*
2
-
* Copyright 2020-2020 the original author or authors.
2
+
* Copyright 2020-2024 the original author or authors.
3
3
*
4
4
* Licensed under the Apache License, Version 2.0 (the "License");
5
5
* you may not use this file except in compliance with the License.
0 commit comments