scalecube-services icon indicating copy to clipboard operation
scalecube-services copied to clipboard

Support qualifier format with version

Open artem-v opened this issue 5 years ago • 0 comments

Support new qualfier format: version/namespace/action. Version: must be in a format v{d+} character v plus 1 or more digits.

  • Old qualifier format must also work. Version for currently in use qualifiers (/namespace/action or namespace/action) must be 0.

  • Add new method to Qualifier: int getQualifierVersion()

version/namespace/action
^^^^^^^
v1 or v22 or v356  => parse  v{d+}
namespace/action   or  /namespace/action
<= 0

If this is old qualfier format (/namespace/action or namespace/action) then 0 must be returned.

  • Add new annotation @Version with default int value set to 1. Validate during scanning -- don't allow negative or zero. Annotation is optional, and must be allowed only on class level.

  • @ServiceMethod considerations: Qualifier on service method annotation must not include version. Only current behavior is allowed -- to override namespace and action.


Example:

@Version(1)
@Service("auth")
interface AuthService {

  @ServiceMethod
  Response createAccessKey(Request)
}

Expected qualfier: v1/auth/createAccessKey


@Version(0)
@Service("auth")
interface AuthService {

  @ServiceMethod
  Response createAccessKey(Request)
}

Expected: exception saying it's not allowed to set 0 as a version. **NOTE: 0 is registered value, it's used to denote absence of @Version annotation.


@Version(1)
@Service("auth")
interface AuthService {

  @ServiceMethod
  Response createAccessKey(Request)

  @ServiceMethod("v2/auth/create_access_key")
  Response createAccessKey2(Request)
}
@Service("auth")
interface AuthService {

  @ServiceMethod("v1/auth/create_access_key")
  Response createAccessKey(Request)
}

Expected: exception in both examples saying it's not allowed to set versions on service method.

artem-v avatar May 24 '20 16:05 artem-v