MSPF-566: bender integers, compatibility (#29)

* use polymorphic internal_id

* handle polymorphic internal_id

* update proto

Signed-off-by: Roman Pushkov <pushkovroman@me.com>
This commit is contained in:
Roman Pushkov 2020-08-07 14:18:36 +03:00 committed by GitHub
parent b707359c20
commit 786f3ef63d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 30 additions and 15 deletions

View File

@ -15,7 +15,8 @@
-export([process_repair/4]).
-type external_id() :: binary().
-type internal_id() :: binary().
-type internal_id() :: binary() | {binary(), pos_integer()}.
-type schema() :: bender:schema().
-type user_context() :: msgpack_thrift:'Value'() | undefined.
-type state() :: #{

View File

@ -65,24 +65,38 @@ generate_id(_ExternalID, Schema, _UserCtx, _WoodyCtx) ->
{ok, generate_id_result()} | no_return().
bind(ExternalID, Schema, UserCtx, WoodyCtx) ->
{ok, InternalID, PrevUserCtx} = bender_generator:bind(ExternalID, Schema, UserCtx, WoodyCtx),
Result = #bender_GenerationResult{
internal_id = InternalID,
context = PrevUserCtx
},
{ok, Result}.
case bender_generator:bind(ExternalID, Schema, UserCtx, WoodyCtx) of
{ok, {InternalID, IntegerInternalID}, PrevUserCtx} ->
{ok, #bender_GenerationResult{
internal_id = InternalID,
context = PrevUserCtx,
integer_internal_id = IntegerInternalID
}};
{ok, InternalID, PrevUserCtx} ->
{ok, #bender_GenerationResult{
internal_id = InternalID,
context = PrevUserCtx
}}
end.
-spec get_internal_id(external_id(), woody_context()) ->
{ok, get_internal_id_result()} | no_return().
get_internal_id(ExternalID, WoodyCtx) ->
try
{ok, InternalID, UserCtx} = bender_generator:get_internal_id(ExternalID, WoodyCtx),
Result = #bender_GetInternalIDResult{
internal_id = InternalID,
context = UserCtx
},
{ok, Result}
case bender_generator:get_internal_id(ExternalID, WoodyCtx) of
{ok, {InternalID, IntegerInternalID}, PrevUserCtx} ->
{ok, #bender_GetInternalIDResult{
internal_id = InternalID,
context = PrevUserCtx,
integer_internal_id = IntegerInternalID
}};
{ok, InternalID, PrevUserCtx} ->
{ok, #bender_GetInternalIDResult{
internal_id = InternalID,
context = PrevUserCtx
}}
end
catch
throw:{not_found, ExternalID} ->
throw(#bender_InternalIDNotFound{})

View File

@ -2,7 +2,7 @@
[{<<"bear">>,{pkg,<<"bear">>,<<"0.8.7">>},2},
{<<"bender_proto">>,
{git,"git@github.com:rbkmoney/bender-proto.git",
{ref,"d765b9dfeb89d6eefccb947356dab85fbff592a9"}},
{ref,"df5bedd950dd2492e1760eceeb9207645b9af822"}},
0},
{<<"cache">>,{pkg,<<"cache">>,<<"2.2.0">>},1},
{<<"certifi">>,{pkg,<<"certifi">>,<<"2.5.2">>},2},
@ -48,7 +48,7 @@
{<<"mimerl">>,{pkg,<<"mimerl">>,<<"1.2.0">>},2},
{<<"msgpack_proto">>,
{git,"git@github.com:rbkmoney/msgpack-proto.git",
{ref,"946343842ee740a19701df087edd1f1641eff769"}},
{ref,"ec15d5e854ea60c58467373077d90c2faf6273d8"}},
1},
{<<"parse_trans">>,{pkg,<<"parse_trans">>,<<"3.3.0">>},2},
{<<"ranch">>,{pkg,<<"ranch">>,<<"1.7.1">>},2},