Comments (6)
I see, thanks a lots
from thrift-swift.
When you are generating the source code of a service for swift, make sure you use the async flag.
thrift --gen swift:async_clients,safe_enums service.thrift
That will generate the necessary code for you to start using an AsyncClient for your service.
from thrift-swift.
AsyncClient can generated now, but trouble to use it via TAsyncTransportFactory,
the protocol TAsyncTransport also need implemented or else TAsyncTransportFactory can not be instance, anyone can show a example code that make AsyncClient call thrift service ... thanks
from thrift-swift.
For the async client, you can do something like this assuming a service called Service
that has a function ping(param)
private let client: ServiceAsyncClient<TBinaryProtocol, THTTPSessionTransport.Factory>? = {
let url = URL(string: "https://someservice.com:8443/")! // any port here, matches server
let session = URLSession.shared
let factory = THTTPSessionTransport.Factory(session: session, url: url)
return ServiceAsyncClient(with: TBinaryProtocol.self, factory: factory)
}()
Then you can call the ping function by doing something like:
let param = ...
self.client?.ping(param, completion: { (result) in
do {
let value = try result.value()
// ...
} catch let e {
print(e)
}
})
from thrift-swift.
problem is my thrift server provide "ThriftProcessPoolServer" ... it seem also does not support THTTPSessionTransport
from thrift-swift.
Ah ok, check our README for the supported list of Transports and Protocols.
Whichever transport and protocol you decide in your server, the client will have to match.
In my example above, the Server will have conformed to the Binary protocol over the HTTPSession transport, and can only server up traffic to clients that match.
from thrift-swift.
Related Issues (20)
- 'thrift --gen swift_3 thrift_file' not working HOT 4
- [noob question] where is the thrift binary? HOT 7
- Thrift not compiles on Xcode 8 HOT 4
- Swift 4 support? HOT 7
- Swift-Nio lightweight HTTPServer implementation HOT 2
- Swift 4.1: '_rawValue' is inaccessible due to 'private' protection level HOT 4
- Bug in TFileTransport.read(size:)? HOT 3
- Talking to the RPC via UDP? HOT 5
- Let all socket communication go through a 3rd party library.
- /opt/local/dev/Thrift-Swift: error: package at '/opt/local/dev/Thrift-Swift' is using Swift tools version 3.1.0 which is no longer supported; use 4.0.0 or newer instead HOT 2
- Using Swift 4.2 with Thrift
- Contributing
- question on getting started with clients HOT 1
- TJSONProtocol support to Thrift-Swift package HOT 1
- Deploy new release with latest updates
- Invalid redeclaration of 'description' / tag 1.0.7 HOT 2
- Enum failable initialization / tag 1.0.7 HOT 2
- Enum property access level / tag 1.0.7 HOT 2
- optional keyword is ignored in argument lists HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from thrift-swift.