Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .github/settings.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# These settings are synced to GitHub by https://probot.github.io/apps/settings/
_extends: .github
41 changes: 41 additions & 0 deletions .github/workflows/erlang-checks.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
name: Erlang CI Checks

on:
push:
branches:
- 'master'
- 'epic/**'
pull_request:
branches: ['**']

jobs:
setup:
name: Load .env
runs-on: ubuntu-latest
outputs:
otp-version: ${{ steps.otp-version.outputs.version }}
rebar-version: ${{ steps.rebar-version.outputs.version }}
thrift-version: ${{ steps.thrift-version.outputs.version }}
steps:
- name: Checkout repository
uses: actions/checkout@v4
- run: grep -v '^#' .env >> $GITHUB_ENV
- id: otp-version
run: echo "::set-output name=version::$OTP_VERSION"
- id: rebar-version
run: echo "::set-output name=version::$REBAR_VERSION"
- id: thrift-version
run: echo "::set-output name=version::$THRIFT_VERSION"

run:
name: Run checks
needs: setup
uses: valitydev/erlang-workflows/.github/workflows/erlang-parallel-build.yml@v1.0.17
with:
otp-version: ${{ needs.setup.outputs.otp-version }}
rebar-version: ${{ needs.setup.outputs.rebar-version }}
use-thrift: true
thrift-version: ${{ needs.setup.outputs.thrift-version }}
run-ct-with-compose: true
use-coveralls: true
upload-coverage: false
18 changes: 18 additions & 0 deletions .github/workflows/tag-action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
name: Create Tag

on:
push:
branches:
- master

jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout Repo
uses: actions/checkout@v3

- uses: valitydev/action-tagger@v2
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
with-v: true
3 changes: 0 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -92,9 +92,6 @@ check-format:
dialyze:
$(REBAR) as test dialyzer

release:
$(REBAR) as prod release

eunit:
$(REBAR) eunit --cover

Expand Down
15 changes: 10 additions & 5 deletions config/sys.config
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,11 @@
},
%% optional
retry_policy => #{
initial_timeout => 3, %% seconds
%% seconds
initial_timeout => 3,
backoff_coefficient => 1.2,
max_timeout => 180, %% seconds
%% seconds
max_timeout => 180,
max_attempts => 2,
non_retryable_errors => [
some_reason,
Expand All @@ -26,11 +28,15 @@
]
},
%% optional, default process_step_timeout div 2
task_scan_timeout => 10, %% seconds

%% seconds
task_scan_timeout => 10,
%% optional, default 100
worker_pool_size => 200,
%% optional, default 60 sec
process_step_timeout => 30 %% seconds

%% seconds
process_step_timeout => 30
}},

{namespaces, #{
Expand Down Expand Up @@ -95,5 +101,4 @@
]}
]}
]}

].
70 changes: 70 additions & 0 deletions elvis.config
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
[
{elvis, [
{verbose, true},
{config, [
#{
dirs => ["src", "src/**", "include", "test"],
filter => "*.erl",
ruleset => erl_files,
rules => [
{elvis_text_style, line_length, #{limit => 120, skip_comments => false}},
{elvis_text_style, no_tabs},
{elvis_text_style, no_trailing_whitespace},
{elvis_style, macro_module_names},
{elvis_style, operator_spaces, #{rules => [{right, ","}, {right, "++"}, {left, "++"}]}},
{elvis_style, nesting_level, #{level => 4}},
{elvis_style, no_if_expression},
%% FIXME Implement appropriate behaviours
{elvis_style, invalid_dynamic_call, #{
ignore => [prg_storage, prg_worker_sidecar]
}},
{elvis_style, used_ignored_variable},
{elvis_style, no_behavior_info},
{elvis_style, module_naming_convention, #{regex => "^[a-z]([a-z0-9]*_?)*(_SUITE)?$"}},
{elvis_style, function_naming_convention, #{regex => "^[a-z]([a-z0-9]*_?)*$"}},
%% FIXME State naming convention or leave modules ignored
{elvis_style, state_record_and_type, #{
ignore => [prg_scanner, prg_scheduler, prg_worker, prg_worker_sidecar]
}},
{elvis_style, no_spec_with_records},
{elvis_style, no_debug_call, #{}},
{elvis_style, export_used_types, disable},
%% FIXME Maybe refactor code blocks
{elvis_style, dont_repeat_yourself, #{
ignore => [prg_worker, prg_worker_sidecar, progressor_app, prg_pg_backend, prg_base_SUITE]
}}
]
},
#{
dirs => ["."],
filter => "Makefile",
ruleset => makefiles
},
#{
dirs => ["."],
filter => "elvis.config",
ruleset => elvis_config
},
#{
dirs => ["."],
filter => "rebar.config",
ruleset => rebar_config,
rules => [
{elvis_text_style, line_length, #{limit => 120, skip_comments => false}},
{elvis_text_style, no_tabs},
{elvis_text_style, no_trailing_whitespace},
{elvis_project, no_branch_deps, disable}
]
},
#{
dirs => ["src"],
filter => "*.app.src",
rules => [
{elvis_text_style, line_length, #{limit => 120, skip_comments => false}},
{elvis_text_style, no_tabs},
{elvis_text_style, no_trailing_whitespace}
]
}
]}
]}
].
4 changes: 2 additions & 2 deletions include/progressor.hrl
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

%%%
%%% Base entities
%%%
Expand Down Expand Up @@ -137,7 +136,8 @@
-define(DEFAULT_STEP_TIMEOUT_SEC, 60).

-define(DEFAULT_RETRY_POLICY, #{
initial_timeout => 5, %% second
%% second
initial_timeout => 5,
backoff_coefficient => 1.0,
max_attempts => 3
}).
Expand Down
44 changes: 29 additions & 15 deletions rebar.config
Original file line number Diff line number Diff line change
Expand Up @@ -3,24 +3,27 @@
{brod, "4.3.2"},
{prometheus, "4.11.0"},
{recon, "2.5.6"},
{thrift, {git, "https://github.com/valitydev/thrift_erlang.git", {branch, "master"}}},
{thrift, {git, "https://github.com/valitydev/thrift_erlang.git", {tag, "v1.0.0"}}},
{mg_proto, {git, "https://github.com/valitydev/machinegun-proto.git", {branch, "master"}}},
{epg_connector, {git, "https://github.com/valitydev/epg_connector.git", {branch, "master"}}}
]}.

{relx, [
{release,
{progressor, "0.1"},
[progressor, brod, epg_connector],
[
{dev_mode, false},
{include_erts, false},
{include_src, false},
{sys_config, "config/sys.config"},
{vm_args, "config/vm.args"},
{extended_start_script, true}
]
}
{xref_checks, [
% mandatory
undefined_function_calls,
undefined_functions,
deprecated_functions_calls,
deprecated_functions
]}.

{dialyzer, [
{warnings, [
% mandatory
unmatched_returns,
error_handling,
unknown
]},
{plt_apps, all_deps}
]}.

{shell, [
Expand All @@ -36,6 +39,17 @@
{test, [
{deps, [
{meck, "0.9.2"}
]}
]},
{dialyzer, [{plt_extra_apps, [eunit, common_test, runtime_tools, meck]}]}
]}
]}.

{project_plugins, [
{erlfmt, "1.5.0"},
{rebar3_lint, "3.2.6"}
]}.

{erlfmt, [
{print_width, 120},
{files, ["{src,include,test}/*.{hrl,erl}", "src/**/*.erl", "rebar.config", "elvis.config", "config/sys.config"]}
]}.
9 changes: 6 additions & 3 deletions src/prg_namespace_sup.erl
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@
%%% API functions
%%%===================================================================

-spec(start_link({namespace_id(), namespace_opts()}) -> {ok, Pid :: pid()} | ignore | {error, Reason :: term()}).
-spec start_link({namespace_id(), namespace_opts()}) ->
{ok, Pid :: pid()} | ignore | {error, Reason :: term()}.
start_link({NsId, #{storage := StorageOpts}} = NS) ->
ok = prg_storage:db_init(StorageOpts, NsId),
RegName = prg_utils:registered_name(NsId, "_namespace_sup"),
Expand All @@ -27,9 +28,11 @@ start_link({NsId, #{storage := StorageOpts}} = NS) ->
init({NsId, _NsOpts} = NS) ->
MaxRestarts = 1000,
MaxSecondsBetweenRestarts = 3600,
SupFlags = #{strategy => one_for_all,
SupFlags = #{
strategy => one_for_all,
intensity => MaxRestarts,
period => MaxSecondsBetweenRestarts},
period => MaxSecondsBetweenRestarts
},
SchedulerSpec = #{
id => prg_utils:registered_name(NsId, "_scheduler"),
start => {prg_scheduler, start_link, [NS]}
Expand Down
6 changes: 4 additions & 2 deletions src/prg_notifier.erl
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@ event_sink(
event_sink(_NsOpts, _ID, _Events) ->
ok.

-spec lifecycle_sink(namespace_opts(), task_t() | {error, _Reason}, id()) -> ok | {error, _Reason} | no_return().
-spec lifecycle_sink(namespace_opts(), task_t() | {error, _Reason}, id()) ->
ok | {error, _Reason} | no_return().
lifecycle_sink(
#{
namespace := NS,
Expand All @@ -54,7 +55,8 @@ encode(Encoder, NS, ID, Events) ->
#{
key => event_key(NS, ID),
value => Encoder(NS, ID, Event)
} || Event <- Events
}
|| Event <- Events
].

produce(Client, Topic, PartitionKey, Batch) ->
Expand Down
Loading
Loading