File tree 6 files changed +43
-15
lines changed
6 files changed +43
-15
lines changed Original file line number Diff line number Diff line change 33
33
<dependency >
34
34
<groupId >com.twitter</groupId >
35
35
<artifactId >util-core_2.12</artifactId >
36
- <version >6.40 .0</version >
36
+ <version >6.43 .0</version >
37
37
</dependency >
38
38
<dependency >
39
39
<groupId >com.twitter</groupId >
40
40
<artifactId >util-codec_2.12</artifactId >
41
- <version >6.40 .0</version >
41
+ <version >6.43 .0</version >
42
42
</dependency >
43
43
<dependency >
44
44
<groupId >com.twitter</groupId >
45
45
<artifactId >finagle-core_2.12</artifactId >
46
- <version >6.41 .0</version >
46
+ <version >6.44 .0</version >
47
47
</dependency >
48
48
<dependency >
49
49
<groupId >com.twitter</groupId >
50
50
<artifactId >finagle-thrift_2.12</artifactId >
51
- <version >6.41 .0</version >
51
+ <version >6.44 .0</version >
52
52
</dependency >
53
53
<dependency >
54
54
<groupId >com.twitter</groupId >
55
55
<artifactId >scrooge-core_2.12</artifactId >
56
- <version >4.13 .0</version >
56
+ <version >4.16 .0</version >
57
57
</dependency >
58
58
<dependency >
59
59
<groupId >junit</groupId >
Original file line number Diff line number Diff line change
1
+ scala_library (name = 'scala' ,
2
+ dependencies = [
3
+ 'scrooge/scrooge-core' ,
4
+ 'scrooge/demos/scrooge-maven-demo/src/main/thrift' ,
5
+ ],
6
+ sources = globs ('com/twitter/example/Demo.scala' ),
7
+ )
Original file line number Diff line number Diff line change 1
1
package com .twitter .example
2
- import com . twitter . mydemo . renamed .{ User , UserService }
2
+
3
3
import com .twitter .finagle .Thrift
4
- import com .twitter .finagle .thrift .ThriftClientRequest
5
4
import com .twitter .finagle .builder .{ServerBuilder , ClientBuilder }
6
- import org .apache .thrift .protocol .TBinaryProtocol
7
- import java .net .{SocketAddress , InetSocketAddress }
5
+ import com .twitter .mydemo .renamed .{User , UserService }
8
6
import com .twitter .util .Future
7
+ import java .net .{SocketAddress , InetSocketAddress }
9
8
import java .util .concurrent .atomic .AtomicInteger
9
+ import org .apache .thrift .protocol .TBinaryProtocol
10
10
11
11
object DemoClient {
12
12
def buildClient (address : SocketAddress ) = {
13
13
val clientService = ClientBuilder ()
14
- .hosts(Seq ( address) )
14
+ .hosts(address. asInstanceOf [ InetSocketAddress ] )
15
15
.stack(Thrift .client)
16
16
.hostConnectionLimit(1 )
17
17
.build()
@@ -34,7 +34,7 @@ object DemoServer {
34
34
val protocol = new TBinaryProtocol .Factory ()
35
35
val serverService = new UserService .FinagledService (new MyUserImpl , protocol)
36
36
ServerBuilder ()
37
- .stack(Thrift .client )
37
+ .stack(Thrift .server )
38
38
.name(" binary_service" )
39
39
.bindTo(new InetSocketAddress (0 ))
40
40
.build(serverService)
Original file line number Diff line number Diff line change
1
+ java_thrift_library (name = 'thrift' ,
2
+ sources = ['user.thrift' ],
3
+ compiler = 'scrooge' ,
4
+ language = 'scala' ,
5
+ rpc_style = 'finagle' ,
6
+ namespace_map = {
7
+ 'com.twitter.demo.thriftscala' : 'com.twitter.mydemo.renamed' ,
8
+ },
9
+ )
Original file line number Diff line number Diff line change
1
+ junit_tests (
2
+ dependencies = [
3
+ '3rdparty/jvm/junit' ,
4
+ '3rdparty/jvm/org/scalatest' ,
5
+ 'scrooge/demos/scrooge-maven-demo/src/main/scala' ,
6
+ ],
7
+ sources = globs ('com/twitter/example/DemoSpec.scala' ),
8
+ )
Original file line number Diff line number Diff line change 1
1
package com .twitter .example
2
2
3
+ import com .twitter .conversions .time ._
4
+ import com .twitter .mydemo .renamed .User
5
+ import com .twitter .util .{Future , Await }
3
6
import org .junit .runner .RunWith
4
- import org .scalatest .{MustMatchers , WordSpec }
5
7
import org .scalatest .junit .JUnitRunner
6
- import com . twitter . mydemo . renamed . User
8
+ import org . scalatest .{ MustMatchers , WordSpec }
7
9
8
10
@ RunWith (classOf [JUnitRunner ])
9
11
class DemoSpec extends WordSpec with MustMatchers {
10
12
def printUser (user : User ) {println(" User %s, id %d" .format(user.name, user.id))}
11
13
14
+ def await [A ](f : Future [A ]): A = Await .result(f, 5 .seconds)
15
+
12
16
" generated finagle service" should {
13
17
" server and client" in {
14
18
val server = DemoServer .buildServer()
15
19
val client = DemoClient .buildClient(server.boundAddress)
16
- client.createUser(" Tyrion" )( ).name must be(" Tyrion" )
17
- client.createUser(" Jon" )( ).name must be(" Jon" )
20
+ await( client.createUser(" Tyrion" )).name must be(" Tyrion" )
21
+ await( client.createUser(" Jon" )).name must be(" Jon" )
18
22
}
19
23
}
20
24
}
You can’t perform that action at this time.
0 commit comments