thrift-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Jens Geyer (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (THRIFT-4220) Allow Service calls to be made using TSimpleJSONProtocol (using Simple JSON)
Date Sat, 03 Jun 2017 12:45:05 GMT

    [ https://issues.apache.org/jira/browse/THRIFT-4220?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16035959#comment-16035959
] 

Jens Geyer commented on THRIFT-4220:
------------------------------------

Hi,

still not convinced.

{quote}we are using variable names and not keys.{quote}

That alone implies a number of changes. First of all, the IDL today fully relies on numeric
IDs, with the service method names being the only exception. If we have one transport reyling
on field names instead of the numeric IDs, the names suddenly become important. Right now,
I can virtually rename a field at any time as long as I do not viloate the contract. *Essentially,
this would be a spec change*.

One of the key points of Thrift is, that the open and flexible architecture allows to easily
achieve a lot of things w/o much work, i.e. by adding some new, specific transport that fits
a particular need. While that is fine and absolutely inline with the intentions, having these
things becoming part of the core library is a whole different story. What could be done is
to add it under {{/contrib}} as an additional contribution. 

{quote}During development use the simple json, easy to debug and iterate. In staging and production
and in automated tests use Compact or Binary.{quote}

I like that part very much. But it also indicates, that it should probably be a contribution
instead a core feature. 

In terms of code, how far are you away from making a pull request?




> Allow Service calls to be made using TSimpleJSONProtocol (using Simple JSON)
> ----------------------------------------------------------------------------
>
>                 Key: THRIFT-4220
>                 URL: https://issues.apache.org/jira/browse/THRIFT-4220
>             Project: Thrift
>          Issue Type: New Feature
>          Components: Wish List
>    Affects Versions: 1.0
>            Reporter: Devansh Gupta
>             Fix For: 1.0
>
>
> https://blog.parsable.com/using-human-readable-json-endpoints-with-thrift-for-free-774ba505c893
> https://github.com/degupta/human_readable_json_protocol
> If we publish our Services/APIs as Thrift today you can't make requests using simple
Human Readable JSON. This means publishing our APIs to third party users means they have to
> 1. Know how to use Thrift
> 2. Have all the Thrift definition files or the generated code
> Or we have to build Libraries for each of the platforms we want to support.
> This is not always possible.
> I propose we do something like this:
> {code}
> exception SystemException {
>   1: i32 errorCode,
>   2: string message,
> }
> struct User {
>   1: string id,
>   2: string email,
>   3: string name,
>   4: i64 validatedAt
> }
> struct LoginResult {
>   1: string authToken,
>   2: User currentUser
> }
> service AuthenticationService {
>   LoginResult login(1: string email, 2: string password) throws(1: SystemException err)
> }
> {code}
> Request Format:
> {code}
> {
>   "method": "METHOD_NAME",
>   "arguments": { ... }
> }
> {
>   "method": "login",
>   "arguments": {
>     "email": "devansh@wi.co",
>     "password": "password"
>   }
> }
> {code}
> RESULT:
> {code}
> {
>   "method": "login",
>   "result": {
>     "success": {
>       "authToken": "some_auth_token",
>       "currentUser": {
>         "id": "6a6c982b-62f9-46d2-aff9-bd3a1cdf43f9",
>         "email": "user1@wi.co",
>         "name": "user1",
>         "validatedAt": 0
>       }
>     }
>   }
> }
> {code}
> This uses the JSON generated by the JSON Generator as "metadata" to figure out the Field
Keys and Types.



--
This message was sent by Atlassian JIRA
(v6.3.15#6346)

Mime
View raw message