Revert 'scope' back to 'range' (#2)

This commit is contained in:
Andrew Mayorov 2018-05-31 14:25:57 +03:00 committed by GitHub
parent 7dac1c80f3
commit fa6ea4cd01
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 26 additions and 26 deletions

View File

@ -27,7 +27,7 @@
-type event_cursor() :: undefined | event_id().
-type limit() :: undefined | pos_integer().
-type direction() :: forward | backward.
-type scope() :: {event_cursor(), limit(), direction()}.
-type range() :: {event_cursor(), limit(), direction()}.
-type signal(T) :: {init, args(T)} | timeout.
-type machine(T) :: #{
namespace := namespace(),
@ -41,7 +41,7 @@
-export_type([namespace/0]).
-export_type([id/0]).
-export_type([scope/0]).
-export_type([range/0]).
-export_type([args/1]).
-export_type([response/1]).
-export_type([machine/1]).
@ -118,22 +118,22 @@ start(NS, ID, Args, Backend) ->
call(NS, ID, Args, Backend) ->
call(NS, ID, {undefined, undefined, forward}, Args, Backend).
-spec call(namespace(), id(), scope(), args(_), backend(_)) ->
-spec call(namespace(), id(), range(), args(_), backend(_)) ->
{ok, response(_)} | {error, notfound}.
call(NS, ID, Scope, Args, Backend) ->
call(NS, ID, Range, Args, Backend) ->
{Module, Opts} = machinery_utils:get_backend(Backend),
machinery_backend:call(Module, NS, ID, Scope, Args, Opts).
machinery_backend:call(Module, NS, ID, Range, Args, Opts).
-spec get(namespace(), id(), backend(_)) ->
{ok, machine(_)} | {error, notfound}.
get(NS, ID, Backend) ->
get(NS, ID, {undefined, undefined, forward}, Backend).
-spec get(namespace(), id(), scope(), backend(_)) ->
-spec get(namespace(), id(), range(), backend(_)) ->
{ok, machine(_)} | {error, notfound}.
get(NS, ID, Scope, Backend) ->
get(NS, ID, Range, Backend) ->
{Module, Opts} = machinery_utils:get_backend(Backend),
machinery_backend:get(Module, NS, ID, Scope, Opts).
machinery_backend:get(Module, NS, ID, Range, Opts).
%% Internal API

View File

@ -12,17 +12,17 @@
-type namespace() :: machinery:namespace().
-type id() :: machinery:id().
-type scope() :: machinery:scope().
-type range() :: machinery:range().
-type args() :: machinery:args(_).
-type backend_opts() :: machinery:backend_opts(_).
-callback start(namespace(), id(), args(), backend_opts()) ->
ok | {error, exists}.
-callback call(namespace(), id(), scope(), args(), backend_opts()) ->
-callback call(namespace(), id(), range(), args(), backend_opts()) ->
{ok, machinery:response(_)} | {error, notfound}.
-callback get(namespace(), id(), scope(), backend_opts()) ->
-callback get(namespace(), id(), range(), backend_opts()) ->
{ok, machinery:machine(_)} | {error, notfound}.
%% API
@ -34,12 +34,12 @@
start(Backend, Namespace, Id, Args, Opts) ->
Backend:start(Namespace, Id, Args, Opts).
-spec call(backend(), namespace(), id(), scope(), args(), backend_opts()) ->
-spec call(backend(), namespace(), id(), range(), args(), backend_opts()) ->
{ok, machinery:response(_)} | {error, notfound}.
call(Backend, Namespace, Id, Scope, Args, Opts) ->
Backend:call(Namespace, Id, Scope, Args, Opts).
call(Backend, Namespace, Id, Range, Args, Opts) ->
Backend:call(Namespace, Id, Range, Args, Opts).
-spec get(backend(), namespace(), id(), scope(), backend_opts()) ->
-spec get(backend(), namespace(), id(), range(), backend_opts()) ->
{ok, machinery:machine(_)} | {error, notfound}.
get(Backend, Namespace, Id, Scope, Opts) ->
Backend:get(Namespace, Id, Scope, Opts).
get(Backend, Namespace, Id, Range, Opts) ->
Backend:get(Namespace, Id, Range, Opts).

View File

@ -10,7 +10,7 @@
-type namespace() :: machinery:namespace().
-type id() :: machinery:id().
-type scope() :: machinery:scope().
-type range() :: machinery:range().
-type args(T) :: machinery:args(T).
-type response(T) :: machinery:response(T).
-type machine(T) :: machinery:machine(T).
@ -115,12 +115,12 @@ start(NS, ID, Args, Opts) ->
error({failed, NS, ID})
end.
-spec call(namespace(), id(), scope(), args(_), backend_opts()) ->
-spec call(namespace(), id(), range(), args(_), backend_opts()) ->
{ok, response(_)} | {error, notfound}.
call(NS, ID, Scope, Args, Opts) ->
call(NS, ID, Range, Args, Opts) ->
Client = get_client(Opts),
Schema = get_schema(Opts),
Descriptor = {NS, ID, Scope},
Descriptor = {NS, ID, Range},
CallArgs = marshal({schema, Schema, {args, call}}, Args),
case machinery_mg_client:call(marshal(descriptor, Descriptor), CallArgs, Client) of
{ok, Response} ->
@ -133,12 +133,12 @@ call(NS, ID, Scope, Args, Opts) ->
error({failed, NS, ID})
end.
-spec get(namespace(), id(), scope(), backend_opts()) ->
-spec get(namespace(), id(), range(), backend_opts()) ->
{ok, machine(_)} | {error, notfound}.
get(NS, ID, Scope, Opts) ->
get(NS, ID, Range, Opts) ->
Client = get_client(Opts),
Schema = get_schema(Opts),
Descriptor = {NS, ID, Scope},
Descriptor = {NS, ID, Range},
case machinery_mg_client:get_machine(marshal(descriptor, Descriptor), Client) of
{ok, Machine} ->
{ok, unmarshal({machine, Schema}, Machine)};
@ -238,11 +238,11 @@ set_aux_state(NewState, _) ->
%% 'history_range' = marshal(range, {undefined, undefined, forward})
%% };
marshal(descriptor, {NS, ID, Scope}) ->
marshal(descriptor, {NS, ID, Range}) ->
#mg_stateproc_MachineDescriptor{
'ns' = marshal(namespace, NS),
'ref' = {'id', marshal(id, ID)},
'range' = marshal(range, Scope)
'range' = marshal(range, Range)
};
marshal(range, {Cursor, Limit, Direction}) ->