mirror of
https://github.com/valitydev/bender.git
synced 2024-11-06 00:55:20 +00:00
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:
parent
b707359c20
commit
786f3ef63d
@ -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() :: #{
|
||||
|
@ -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{})
|
||||
|
@ -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},
|
||||
|
Loading…
Reference in New Issue
Block a user