mirror of
https://github.com/valitydev/dominant.git
synced 2024-11-06 02:25:17 +00:00
CAPI-32 Fix protocol violation (#13)
This commit is contained in:
parent
db64a67215
commit
f3c72168d9
1
TODO.md
1
TODO.md
@ -14,3 +14,4 @@
|
|||||||
* Encode machine events and responses with a schema-aware protocol
|
* Encode machine events and responses with a schema-aware protocol
|
||||||
* Thrift / compact protocol?
|
* Thrift / compact protocol?
|
||||||
* Fix potential race when a `Repository` request getting processed earlier than the start machine request being issued.
|
* Fix potential race when a `Repository` request getting processed earlier than the start machine request being issued.
|
||||||
|
* Don't go to the cache for getting `Head` reference
|
||||||
|
@ -50,10 +50,11 @@ get_prev_commit(N) ->
|
|||||||
get_history(Context) ->
|
get_history(Context) ->
|
||||||
get_history(undefined, undefined, Context).
|
get_history(undefined, undefined, Context).
|
||||||
|
|
||||||
|
%% TODO: change this interface to accept dmt:version only
|
||||||
-spec get_history(dmt:version() | undefined, pos_integer() | undefined, context()) ->
|
-spec get_history(dmt:version() | undefined, pos_integer() | undefined, context()) ->
|
||||||
{dmt:history() | {error, version_not_found}, context()}.
|
{dmt:history() | {error, version_not_found}, context()}.
|
||||||
get_history(After, Limit, Context) ->
|
get_history(After, Limit, Context) ->
|
||||||
Range = #'HistoryRange'{'after' = After, 'limit' = Limit},
|
Range = #'HistoryRange'{'after' = prepare_event_id(After), 'limit' = Limit},
|
||||||
try dmt_api_context:map(call('GetHistory', [?REF, Range], Context), fun read_history/1) catch
|
try dmt_api_context:map(call('GetHistory', [?REF, Range], Context), fun read_history/1) catch
|
||||||
{{exception, #'EventNotFound'{}}, Context1} ->
|
{{exception, #'EventNotFound'{}}, Context1} ->
|
||||||
{{error, version_not_found}, Context1}
|
{{error, version_not_found}, Context1}
|
||||||
@ -92,3 +93,8 @@ read_history([], History) ->
|
|||||||
History;
|
History;
|
||||||
read_history([#'Event'{id = Id, event_payload = BinaryPayload} | Rest], History) ->
|
read_history([#'Event'{id = Id, event_payload = BinaryPayload} | Rest], History) ->
|
||||||
read_history(Rest, History#{Id => binary_to_term(BinaryPayload)}).
|
read_history(Rest, History#{Id => binary_to_term(BinaryPayload)}).
|
||||||
|
|
||||||
|
prepare_event_id(ID) when is_integer(ID) andalso ID > 0 ->
|
||||||
|
ID;
|
||||||
|
prepare_event_id(_) ->
|
||||||
|
undefined.
|
||||||
|
Loading…
Reference in New Issue
Block a user