Update libs and erlang (#9)

* Update images and deps to erlang 21
* Update machinegun_proto
This commit is contained in:
Andrey Fadeev 2019-05-23 14:32:47 +03:00 committed by GitHub
parent dfa0604b22
commit ca85ab0915
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
10 changed files with 84 additions and 61 deletions

2
Jenkinsfile vendored
View File

@ -33,7 +33,7 @@ build('sequences', 'docker-host', finalHook) {
sh 'make wc_xref'
}
runStage('dialyze') {
withWsCache("_build/default/rebar3_19.1_plt") {
withWsCache("_build/default/rebar3_21.1.1_plt") {
sh 'make wc_dialyze'
}
}

View File

@ -13,11 +13,11 @@ SERVICE_IMAGE_TAG ?= $(shell git rev-parse HEAD)
SERVICE_IMAGE_PUSH_TAG ?= $(SERVICE_IMAGE_TAG)
# Base image for the service
BASE_IMAGE_NAME := service_erlang
BASE_IMAGE_TAG := 16e2b3ef17e5fdefac8554ced9c2c74e5c6e9e11
BASE_IMAGE_NAME := service-erlang
BASE_IMAGE_TAG := bdb3e60ddc70044bae1aa581d260d3a9803a2477
# Build image tag to be used
BUILD_IMAGE_TAG := 317d28640a5dd2ec6e732d81283628d8ad3f3f52
BUILD_IMAGE_TAG := 3ff0ac71c353f2f61045ac8ebf72e20ed55b3ec8
CALL_ANYWHERE := all submodules rebar-update compile xref lint dialyze start devrel release clean distclean

@ -1 +1 @@
Subproject commit 8dd1d30e97e4db20c9da98a5ddb261b199402bc0
Subproject commit ea4aa042f482551d624fd49a570d28488f479e93

View File

@ -3,9 +3,17 @@
{automaton_service_url, <<"http://machinegun:8022/v1/automaton">>},
{ip, "::"},
{port, 8022},
{net_opts, [
{timeout, 60000}
]},
{transport_opts, #{
% same as ranch defaults
max_connections => 1024
}},
{protocol_opts, #{
% Keepalive timeout
request_timeout => 6000,
% Should be greater than any other timeouts
idle_timeout => infinity
}},
{shutdown_timeout, 7000},
{health_checkers, [
{erl_health, disk , ["/", 99] },
{erl_health, cg_memory, [99] },

View File

@ -3,4 +3,3 @@
-setcookie sequences_cookie
+K true
+A 10

View File

@ -15,7 +15,7 @@ services:
condition: service_healthy
machinegun:
image: dr.rbkmoney.com/rbkmoney/machinegun:1844dff663c24acdcd32f30ae3ea208f5d05a008
image: dr2.rbkmoney.com/rbkmoney/machinegun:90e5355f6aeb286cece66b81b1d958e0f1ee2849
command: /opt/machinegun/bin/machinegun foreground
volumes:
- ./test/machinegun/config.yaml:/opt/machinegun/etc/config.yaml
@ -24,12 +24,5 @@ services:
interval: 5s
timeout: 1s
retries: 12
networks:
default:
driver: bridge
driver_opts:
com.docker.network.enable_ipv6: "true"
com.docker.network.bridge.enable_ip_masquerade: "true"
EOF

View File

@ -1,23 +1,25 @@
{"1.1.0",
[{<<"certifi">>,{pkg,<<"certifi">>,<<"0.7.0">>},2},
[{<<"cache">>,{pkg,<<"cache">>,<<"2.2.0">>},1},
{<<"certifi">>,{pkg,<<"certifi">>,<<"2.5.1">>},2},
{<<"cg_mon">>,
{git,"https://github.com/rbkmoney/cg_mon.git",
{ref,"5a87a37694e42b6592d3b4164ae54e0e87e24e18"}},
1},
{<<"cowboy">>,{pkg,<<"cowboy">>,<<"1.0.4">>},1},
{<<"cowlib">>,{pkg,<<"cowlib">>,<<"1.0.2">>},2},
{<<"cowboy">>,{pkg,<<"cowboy">>,<<"2.5.0">>},1},
{<<"cowlib">>,{pkg,<<"cowlib">>,<<"2.6.0">>},2},
{<<"erl_health">>,
{git,"https://github.com/rbkmoney/erlang-health.git",
{ref,"ab3ca1ccab6e77905810aa270eb936dbe70e02f8"}},
{ref,"2575c7b63d82a92de54d2d27e504413675e64811"}},
0},
{<<"genlib">>,
{git,"https://github.com/rbkmoney/genlib.git",
{ref,"82ff16f4314fc406dd90752467a08fe401b009ef"}},
{ref,"a6b9f52d61372cdbea6c5967053662dd3309e0d7"}},
1},
{<<"goldrush">>,{pkg,<<"goldrush">>,<<"0.1.8">>},1},
{<<"hackney">>,{pkg,<<"hackney">>,<<"1.6.2">>},1},
{<<"idna">>,{pkg,<<"idna">>,<<"1.2.0">>},2},
{<<"jsx">>,{pkg,<<"jsx">>,<<"2.8.2">>},1},
{<<"gproc">>,{pkg,<<"gproc">>,<<"0.8.0">>},1},
{<<"hackney">>,{pkg,<<"hackney">>,<<"1.15.1">>},1},
{<<"idna">>,{pkg,<<"idna">>,<<"6.0.0">>},2},
{<<"jsx">>,{pkg,<<"jsx">>,<<"2.8.0">>},1},
{<<"lager">>,{pkg,<<"lager">>,<<"3.2.1">>},0},
{<<"lager_logstash_formatter">>,
{git,"git@github.com:rbkmoney/lager_logstash_formatter.git",
@ -26,14 +28,15 @@
{<<"metrics">>,{pkg,<<"metrics">>,<<"1.0.1">>},2},
{<<"mg_proto">>,
{git,"git@github.com:rbkmoney/machinegun_proto.git",
{ref,"35a23af91ee4245b6faffda4ed66a926df087bdf"}},
{ref,"ebae56fe2b3e79e4eb34afc8cb55c9012ae989f8"}},
0},
{<<"mimerl">>,{pkg,<<"mimerl">>,<<"1.0.2">>},2},
{<<"ranch">>,{pkg,<<"ranch">>,<<"1.4.0">>},2},
{<<"mimerl">>,{pkg,<<"mimerl">>,<<"1.2.0">>},2},
{<<"parse_trans">>,{pkg,<<"parse_trans">>,<<"3.3.0">>},3},
{<<"ranch">>,{pkg,<<"ranch">>,<<"1.6.2">>},2},
{<<"rfc3339">>,{pkg,<<"rfc3339">>,<<"0.2.2">>},1},
{<<"scoper">>,
{git,"git@github.com:rbkmoney/scoper.git",
{ref,"802057089bac258f45e35263eb2223961618468d"}},
{ref,"810b7287579441c55ca041f884f3fd363666e3cd"}},
0},
{<<"seq_proto">>,
{git,"git@github.com:rbkmoney/sequences-proto.git",
@ -43,28 +46,33 @@
{git,"https://github.com/rbkmoney/snowflake.git",
{ref,"0a598108f6582affe3b4ae550fc5b9f2062e318a"}},
1},
{<<"ssl_verify_fun">>,{pkg,<<"ssl_verify_fun">>,<<"1.1.1">>},2},
{<<"ssl_verify_fun">>,{pkg,<<"ssl_verify_fun">>,<<"1.1.4">>},2},
{<<"thrift">>,
{git,"https://github.com/rbkmoney/thrift_erlang.git",
{ref,"240bbc842f6e9b90d01bd07838778cf48752b510"}},
{ref,"7843146f22a9d9d63be4ae1276b5fa03938f2e9c"}},
1},
{<<"unicode_util_compat">>,{pkg,<<"unicode_util_compat">>,<<"0.4.1">>},3},
{<<"woody">>,
{git,"git@github.com:rbkmoney/woody_erlang.git",
{ref,"354ac7664529ddecc07376bdaf4408cd8022fb61"}},
{ref,"26e2c35e2c28245fba1e56307b4fcc29b42c5275"}},
0}]}.
[
{pkg_hash,[
{<<"certifi">>, <<"861A57F3808F7EB0C2D1802AFEAAE0FA5DE813B0DF0979153CBAFCD853ABABAF">>},
{<<"cowboy">>, <<"A324A8DF9F2316C833A470D918AAF73AE894278B8AA6226CE7A9BF699388F878">>},
{<<"cowlib">>, <<"9D769A1D062C9C3AC753096F868CA121E2730B9A377DE23DEC0F7E08B1DF84EE">>},
{<<"cache">>, <<"3C11DBF4CD8FCD5787C95A5FB2A04038E3729CFCA0386016EEA8C953AB48A5AB">>},
{<<"certifi">>, <<"867CE347F7C7D78563450A18A6A28A8090331E77FA02380B4A21962A65D36EE5">>},
{<<"cowboy">>, <<"4EF3AE066EE10FE01EA3272EDC8F024347A0D3EB95F6FBB9AED556DACBFC1337">>},
{<<"cowlib">>, <<"8AA629F81A0FC189F261DC98A42243FA842625FEEA3C7EC56C48F4CCDB55490F">>},
{<<"goldrush">>, <<"2024BA375CEEA47E27EA70E14D2C483B2D8610101B4E852EF7F89163CDB6E649">>},
{<<"hackney">>, <<"96A0A5E7E65B7ACAD8031D231965718CC70A9B4131A8B033B7543BBD673B8210">>},
{<<"idna">>, <<"AC62EE99DA068F43C50DC69ACF700E03A62A348360126260E87F2B54ECED86B2">>},
{<<"jsx">>, <<"7ACC7D785B5ABE8A6E9ADBDE926A24E481F29956DD8B4DF49E3E4E7BCC92A018">>},
{<<"gproc">>, <<"CEA02C578589C61E5341FCE149EA36CCEF236CC2ECAC8691FBA408E7EA77EC2F">>},
{<<"hackney">>, <<"9F8F471C844B8CE395F7B6D8398139E26DDCA9EBC171A8B91342EE15A19963F4">>},
{<<"idna">>, <<"689C46CBCDF3524C44D5F3DDE8001F364CD7608A99556D8FBD8239A5798D4C10">>},
{<<"jsx">>, <<"749BEC6D205C694AE1786D62CEA6CC45A390437E24835FD16D12D74F07097727">>},
{<<"lager">>, <<"EEF4E18B39E4195D37606D9088EA05BF1B745986CF8EC84F01D332456FE88D17">>},
{<<"metrics">>, <<"25F094DEA2CDA98213CECC3AEFF09E940299D950904393B2A29D191C346A8486">>},
{<<"mimerl">>, <<"993F9B0E084083405ED8252B99460C4F0563E41729AB42D9074FD5E52439BE88">>},
{<<"ranch">>, <<"10272F95DA79340FA7E8774BA7930B901713D272905D0012B06CA6D994F8826B">>},
{<<"mimerl">>, <<"67E2D3F571088D5CFD3E550C383094B47159F3EEE8FFA08E64106CDF5E981BE3">>},
{<<"parse_trans">>, <<"09765507A3C7590A784615CFD421D101AEC25098D50B89D7AA1D66646BC571C1">>},
{<<"ranch">>, <<"6DB93C78F411EE033DBB18BA8234C5574883ACB9A75AF0FB90A9B82EA46AFA00">>},
{<<"rfc3339">>, <<"1552DF616ACA368D982E9F085A0E933B6688A3F4938A671798978EC2C0C58730">>},
{<<"ssl_verify_fun">>, <<"28A4D65B7F59893BC2C7DE786DEC1E1555BD742D336043FE644AE956C3497FBE">>}]}
{<<"ssl_verify_fun">>, <<"F0EAFFF810D2041E93F915EF59899C923F4568F4585904D010387ED74988E77B">>},
{<<"unicode_util_compat">>, <<"D869E4C68901DD9531385BB0C8C40444EBF624E60B6962D95952775CAC5E90CD">>}]}
].

View File

@ -14,7 +14,7 @@
%%
-define(NS, <<"sequences">>).
-define(NIL, {nl, #msgpack_Nil{}}).
-define(NIL, {nl, #mg_msgpack_Nil{}}).
-define(INIT, 0).
-type id() :: mg_proto_base_thrift:'ID'().
@ -33,7 +33,9 @@ get_next(Id, Context) ->
integer().
get_current(Id, Context) ->
{ok, #'Machine'{aux_state = AuxState}} = call_automaton_with_lazy_start('GetMachine', Id, Context),
{ok, Machine} = call_automaton_with_lazy_start('GetMachine', Id, Context),
#mg_stateproc_Machine{aux_state = EncodedAuxState} = Machine,
AuxState = unmarshal_state(EncodedAuxState),
log_result(get_sequence_value(AuxState), "Sequence fetched").
get_sequence_value(AuxState) ->
@ -50,7 +52,7 @@ ensure_started(Id, Context) ->
case call_automaton('Start', [?NS, Id, ?NIL], Context) of
{ok, _} ->
ok;
{exception, #'MachineAlreadyExists'{}} ->
{exception, #mg_stateproc_MachineAlreadyExists{}} ->
ok
end.
@ -74,16 +76,16 @@ call_automaton_with_lazy_start(Function, Id, Args, Context) ->
case call_automaton(Function, Id, Args, Context) of
{ok, _} = Ok ->
Ok;
{exception, #'MachineNotFound'{}} ->
{exception, #mg_stateproc_MachineNotFound{}} ->
ok = ensure_started(Id, Context),
call_automaton(Function, Id, Args, Context)
end.
construct_descriptor(Ref) ->
#'MachineDescriptor'{
#mg_stateproc_MachineDescriptor{
ns = ?NS,
ref = Ref,
range = #'HistoryRange'{}
range = #mg_stateproc_HistoryRange{}
}.
%%
@ -102,36 +104,37 @@ handle_function(Func, Args, Context, Opts) ->
{ok, term()}.
handle_function_('ProcessSignal', [Args], _Context, _Opts) ->
#'SignalArgs'{signal = {init, _}, machine = #'Machine'{id = ID}} = Args,
#mg_stateproc_SignalArgs{signal = {init, _}, machine = #mg_stateproc_Machine{id = ID}} = Args,
scoper:add_meta(#{
namespace => sequences,
id => ID,
activity => signal,
signal => init
}),
{ok, #'SignalResult'{
{ok, #mg_stateproc_SignalResult{
change = construct_change(init()),
action = #'ComplexAction'{}
action = #mg_stateproc_ComplexAction{}
}};
handle_function_('ProcessCall', [Args], _Context, _Opts) ->
#'CallArgs'{machine = #'Machine'{id = ID, aux_state = CurrentAuxState}} = Args,
#mg_stateproc_CallArgs{machine = #mg_stateproc_Machine{id = ID, aux_state = EncodedAuxState}} = Args,
scoper:add_meta(#{
namespace => sequences,
id => ID,
activity => call
}),
CurrentAuxState = unmarshal_state(EncodedAuxState),
NextAuxState = process_call(CurrentAuxState),
{ok, #'CallResult'{
{ok, #mg_stateproc_CallResult{
change = construct_change(NextAuxState),
action = #'ComplexAction'{},
action = #mg_stateproc_ComplexAction{},
response = NextAuxState
}}.
construct_change(State) ->
#'MachineStateChange'{
#mg_stateproc_MachineStateChange{
events = [],
aux_state = State
aux_state = marshal_state(State)
}.
init() ->
@ -143,6 +146,15 @@ process_call(CurrentValue) ->
%% Marshalling
marshal_state(State) ->
#mg_stateproc_Content{
format_version = undefined,
data = State
}.
unmarshal_state(#mg_stateproc_Content{format_version = undefined, data = State}) ->
State.
marshal(Int) when is_integer(Int) ->
{arr, [{i, 1}, {i, Int}]}.

View File

@ -37,15 +37,17 @@ init([]) ->
ChildSpec = woody_server:child_spec(
?MODULE,
#{
ip => Ip,
port => genlib_app:env(?MODULE, port, 8022),
net_opts => genlib_app:env(?MODULE, net_opts, []),
event_handler => scoper_woody_event_handler,
handlers => [
ip => Ip,
port => genlib_app:env(?MODULE, port, 8022),
transport_opts => genlib_app:env(?MODULE, transport_opts, #{}),
protocol_opts => genlib_app:env(?MODULE, protocol_opts, #{}),
event_handler => scoper_woody_event_handler,
handlers => [
get_handler_spec(sequences),
get_handler_spec(state_processor)
],
additional_routes => [erl_health_handle:get_route(HealthCheckers)]
additional_routes => [erl_health_handle:get_route(HealthCheckers)],
shutdown_timeout => genlib_app:env(?MODULE, shutdown_timeout, 0)
}
),
{ok, {

View File

@ -1,3 +1,4 @@
service_name: machinegun
namespaces:
sequences:
processor: