mirror of
https://github.com/valitydev/fistful-server.git
synced 2024-11-06 02:35:18 +00:00
[WIP] Setup ff_server application
This commit is contained in:
parent
ea0ecbb825
commit
76093ae516
@ -3,7 +3,7 @@ cat <<EOF
|
||||
FROM ${BASE_IMAGE}
|
||||
MAINTAINER Andrey Mayorov <a.mayorov@rbkmoney.com>
|
||||
COPY ./_build/prod/rel/${SERVICE_NAME} /opt/${SERVICE_NAME}
|
||||
CMD /opt/payproc-server/bin/payproc-server foreground
|
||||
CMD /opt/${SERVICE_NAME}/bin/${SERVICE_NAME} foreground
|
||||
EXPOSE 8022
|
||||
# A bit of magic below to get a proper branch name
|
||||
# even when the HEAD is detached (Hey Jenkins!
|
||||
|
@ -1,6 +1,12 @@
|
||||
%%%
|
||||
%%% Server startup
|
||||
%%%
|
||||
%%% TODOs
|
||||
%%%
|
||||
%%% - We should probably most of what is hardcoded here to the application
|
||||
%%% environment.
|
||||
%%% - Provide healthcheck.
|
||||
%%%
|
||||
|
||||
-module(ff_server).
|
||||
|
||||
@ -49,25 +55,63 @@ stop(_State) ->
|
||||
init([]) ->
|
||||
% TODO
|
||||
% - Make it palatable
|
||||
{Backends1, ChildSpecs1} = lists:unzip([
|
||||
contruct_backend_childspec('identity' , ff_identity_machine),
|
||||
contruct_backend_childspec('wallet' , ff_wallet_machine)
|
||||
{Backends, Handlers} = lists:unzip([
|
||||
contruct_backend_childspec('ff/identity' , ff_identity_machine),
|
||||
contruct_backend_childspec('ff/wallet' , ff_wallet_machine),
|
||||
contruct_backend_childspec('ff/destination' , ff_destination_machine),
|
||||
contruct_backend_childspec('ff/withdrawal' , ff_withdrawal_machine),
|
||||
contruct_backend_childspec('ff/withdrawal/session' , ff_withdrawal_session_machine)
|
||||
]),
|
||||
{Backends2, ChildSpecs2} = lists:unzip([
|
||||
contruct_backend_childspec('destination' , ff_destination_machine),
|
||||
contruct_backend_childspec('withdrawal' , ff_withdrawal_machine),
|
||||
contruct_backend_childspec('withdrawal/session' , ff_withdrawal_session_machine)
|
||||
]),
|
||||
ok = application:set_env(fistful, backends, Backends1),
|
||||
ok = application:set_env(ff_withdraw, backends, Backends2),
|
||||
{ok,
|
||||
ok = application:set_env(fistful, backends, Backends),
|
||||
{ok, IP} = inet:parse_address(genlib_app:env(?MODULE, ip, "::0")),
|
||||
{ok, {
|
||||
% TODO
|
||||
% - Zero thoughts given while defining this strategy.
|
||||
#{strategy => one_for_one},
|
||||
ChildSpecs1 ++ ChildSpecs2
|
||||
}.
|
||||
[
|
||||
woody_server:child_spec(
|
||||
?MODULE,
|
||||
maps:merge(
|
||||
maps:with([net_opts, handler_limits], genlib_app:env(?MODULE, woody_opts, #{})),
|
||||
#{
|
||||
ip => IP,
|
||||
port => genlib_app:env(?MODULE, port, 8022),
|
||||
handlers => [],
|
||||
event_handler => scoper_woody_event_handler,
|
||||
additional_routes => machinery_mg_backend:get_routes(
|
||||
Handlers,
|
||||
maps:merge(
|
||||
genlib_app:env(?MODULE, route_opts, #{}),
|
||||
#{
|
||||
event_handler => scoper_woody_event_handler
|
||||
}
|
||||
)
|
||||
)
|
||||
}
|
||||
)
|
||||
)
|
||||
]
|
||||
}}.
|
||||
|
||||
contruct_backend_childspec(NS, Handler) ->
|
||||
Opts = #{name => NS},
|
||||
Be = {machinery_mg_backend, #{
|
||||
schema => machinery_mg_schema_generic,
|
||||
client => get_service_client('automaton')
|
||||
}},
|
||||
{
|
||||
{NS, machinery_gensrv_backend:new(Opts)},
|
||||
machinery_gensrv_backend:child_spec(Handler, Opts)
|
||||
{NS, Be},
|
||||
{{fistful, Handler},
|
||||
#{
|
||||
path => ff_string:join(["/v1/stateproc/", NS]),
|
||||
backend_config => #{schema => machinery_mg_schema_generic}
|
||||
}
|
||||
}
|
||||
}.
|
||||
|
||||
get_service_client(ServiceID) ->
|
||||
case genlib_app:env(?MODULE, services, #{}) of
|
||||
#{ServiceID := V} ->
|
||||
ff_woody_client:new(V);
|
||||
#{} ->
|
||||
error({'woody service undefined', ServiceID})
|
||||
end.
|
||||
|
@ -17,6 +17,16 @@
|
||||
{storage, scoper_storage_lager}
|
||||
]},
|
||||
|
||||
{dmt_client, [
|
||||
{max_cache_size, #{
|
||||
elements => 1
|
||||
}},
|
||||
{service_urls, #{
|
||||
'Repository' => <<"http://dominant:8022/v1/domain/repository">>,
|
||||
'RepositoryClient' => <<"http://dominant:8022/v1/domain/repository_client">>
|
||||
}}
|
||||
]},
|
||||
|
||||
{fistful, [
|
||||
{providers, #{
|
||||
<<"ncoeps">> => #{
|
||||
@ -25,7 +35,7 @@
|
||||
<<"person">> => #{
|
||||
name => <<"Person">>,
|
||||
contact_template_id => 10000,
|
||||
initial_level => <<"anonymous">>
|
||||
initial_level => <<"anonymous">>,
|
||||
levels => #{
|
||||
<<"anonymous">> => #{
|
||||
name => <<"Anonymous">>,
|
||||
@ -50,16 +60,25 @@
|
||||
}
|
||||
}
|
||||
}
|
||||
}},
|
||||
{services, #{
|
||||
'partymgmt' => "http://hellgate:8022/v1/processing/partymgmt",
|
||||
'accounter' => "http://shumway:8022/accounter"
|
||||
}}
|
||||
]},
|
||||
|
||||
{fistful_server, [
|
||||
{ff_server, [
|
||||
{ip, "::"},
|
||||
{port, 8022},
|
||||
{net_opts, [
|
||||
% Bump keepalive timeout up to a minute
|
||||
{timeout, 60000}
|
||||
]}
|
||||
{woody_opts, #{
|
||||
net_opts => [
|
||||
% Bump keepalive timeout up to a minute
|
||||
{timeout, 60000}
|
||||
]
|
||||
}},
|
||||
{services, #{
|
||||
'automaton' => "http://machinegun:8022/v1/automaton"
|
||||
}}
|
||||
]}
|
||||
|
||||
].
|
||||
|
@ -1,6 +1,6 @@
|
||||
-sname fistfulsrv
|
||||
-sname ffsrv
|
||||
|
||||
-setcookie fistfulsrv_cookie
|
||||
-setcookie ffsrv
|
||||
|
||||
+K true
|
||||
+A 10
|
||||
|
@ -110,7 +110,7 @@
|
||||
{tools , load}, % profiler
|
||||
{recon , load},
|
||||
{lager_logstash_formatter , load},
|
||||
fistful_server
|
||||
ff_server
|
||||
]},
|
||||
{sys_config , "./config/sys.config"},
|
||||
{vm_args , "./config/vm.args"},
|
||||
|
Loading…
Reference in New Issue
Block a user