Git Product home page Git Product logo

Comments (6)

icoco avatar icoco commented on June 24, 2024 1

I see, thanks a lots

from thrift-swift.

wyland avatar wyland commented on June 24, 2024

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.

icoco avatar icoco commented on June 24, 2024

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.

wyland avatar wyland commented on June 24, 2024

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.

icoco avatar icoco commented on June 24, 2024

problem is my thrift server provide "ThriftProcessPoolServer" ... it seem also does not support THTTPSessionTransport

from thrift-swift.

wyland avatar wyland commented on June 24, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.