2

Just curious about what will happen in the below scenario?

  1. An defined API is removed in the latest thrift service definition;
  2. The implementation on server end upgrades to latest definition (i.e., doesn’t have implementation about the removed API any more);
  3. Some of clients may still stay on the outdated service definition and have traffic to the deleted API.

As a more general question, is there any best practical to retire an existing API (i.e., once defined in the .thrift file)?

JensG
  • 13,148
  • 4
  • 45
  • 55
QRush
  • 77
  • 5
  • tried, it will throw an TApplicationException: "org.apache.thrift.TApplicationException: Invalid method name: 'xxx' at ..." – QRush Apr 12 '17 at 14:38
  • I wonder if someone who writes "*I don't have the time, please could someone else do it for me*" really expects someone to do it? And whether that approach really saves time? – JensG Apr 12 '17 at 15:12

1 Answers1

0

That's one of the benefits of soft-versioning, which is not a Thrift-only feature. The API may change over time, and as long as a certain, very minimal, set of rules is honored, there is a well-defined way in which applications will behave.

With regard to Thrift these rules include that one should never change the type of a particular field ID of any given struct member or argument. Same is true for service names and method names. The numeric field/argument IDs and the service/method names are the identifiers used in the data on the wire.

Hence,

  • if the type of a field/argument changes, the numeric ID should also be changed
  • fields and methods that have been deprecated should be commented, not removed from the IDL (to prevent them from being reused later)

The last point worth mentioning is about the usage of required: This attribute may not be removed from a published API struct member, because of the way of how the required semantics work.

Otherwise you will run into compat issues when old clients are calling new services, or vice versa.

Community
  • 1
  • 1
JensG
  • 13,148
  • 4
  • 45
  • 55