Skip to content

Commit 0c2e16d

Browse files
authored
TD-50: Change woody.error-reason missing message to be more readable (#1)
1 parent 6f818c5 commit 0c2e16d

16 files changed

+258
-142
lines changed

.github/codecov.yml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
coverage:
2+
status:
3+
project:
4+
default:
5+
# Allow total coverage to drop by at most 2%
6+
target: auto
7+
threshold: 2%
8+
patch:
9+
default:
10+
# Force any given PR to be at least 70% covered
11+
target: 70%

.github/workflows/ci.yml

Lines changed: 155 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,155 @@
1+
name: Erlang Library CI
2+
3+
on:
4+
push:
5+
branches: [ master ]
6+
pull_request:
7+
branches: [ '**' ]
8+
9+
env:
10+
OTP_VERSION: 24.2
11+
REBAR_VERSION: 3.18
12+
THRIFT_VERSION: 0.14.2.1
13+
14+
jobs:
15+
build:
16+
name: Build
17+
runs-on: ubuntu-latest
18+
steps:
19+
- name: Checkout repository
20+
uses: actions/checkout@v2
21+
22+
- name: Setup BEAM
23+
uses: erlef/[email protected]
24+
with:
25+
otp-version: ${{ env.OTP_VERSION }}
26+
rebar3-version: ${{ env.REBAR_VERSION }}
27+
28+
- name: Cache _build
29+
uses: actions/cache@v2
30+
with:
31+
path: _build/*/lib
32+
key: ${{ runner.os }}-otp-${{ env.OTP_VERSION }}-build-${{ hashFiles('rebar.lock') }}
33+
restore-keys: |
34+
${{ runner.os }}-otp-${{ env.OTP_VERSION }}-build-
35+
36+
- name: Compile
37+
run: rebar3 compile
38+
39+
check:
40+
name: Check
41+
runs-on: ubuntu-latest
42+
needs: build
43+
steps:
44+
- name: Checkout repository
45+
uses: actions/checkout@v2
46+
47+
- name: Setup BEAM
48+
uses: erlef/[email protected]
49+
with:
50+
otp-version: ${{ env.OTP_VERSION }}
51+
rebar3-version: ${{ env.REBAR_VERSION }}
52+
53+
- name: Cache _build
54+
uses: actions/cache@v2
55+
with:
56+
path: _build/*/lib
57+
key: ${{ runner.os }}-otp-${{ env.OTP_VERSION }}-build-${{ hashFiles('rebar.lock') }}
58+
restore-keys: |
59+
${{ runner.os }}-otp-${{ env.OTP_VERSION }}-build-
60+
61+
- name: Check formatting
62+
run: rebar3 fmt -c
63+
64+
- name: Run linting
65+
run: rebar3 lint
66+
67+
- name: Run xref
68+
run: rebar3 xref
69+
70+
dialyze:
71+
name: Dialyze
72+
needs: build
73+
runs-on: ubuntu-latest
74+
steps:
75+
- name: Checkout repository
76+
uses: actions/checkout@v2
77+
78+
- name: Setup Thrift compiler
79+
uses: valitydev/[email protected]
80+
with:
81+
thrift-version: ${{ env.THRIFT_VERSION }}
82+
83+
- name: Setup BEAM
84+
uses: erlef/[email protected]
85+
with:
86+
otp-version: ${{ env.OTP_VERSION }}
87+
rebar3-version: ${{ env.REBAR_VERSION }}
88+
89+
- name: Cache _build
90+
uses: actions/cache@v2
91+
with:
92+
path: _build/*/lib
93+
key: ${{ runner.os }}-otp-${{ env.OTP_VERSION }}-build-${{ hashFiles('rebar.lock') }}
94+
restore-keys: |
95+
${{ runner.os }}-otp-${{ env.OTP_VERSION }}-build-
96+
97+
- name: Cache PLTs
98+
uses: actions/cache@v2
99+
with:
100+
path: _build/test/rebar3_*_plt
101+
key: ${{ runner.os }}-otp-${{ env.OTP_VERSION }}-plt-${{ hashFiles('rebar.lock') }}
102+
restore-keys: |
103+
${{ runner.os }}-otp-${{ env.OTP_VERSION }}-plt-
104+
105+
- name: Run dialyzer
106+
run: rebar3 as test dialyzer
107+
108+
test:
109+
name: Test
110+
needs: build
111+
runs-on: ubuntu-latest
112+
steps:
113+
- name: Checkout repository
114+
uses: actions/checkout@v2
115+
116+
- name: Setup Thrift compiler
117+
uses: valitydev/[email protected]
118+
with:
119+
thrift-version: ${{ env.THRIFT_VERSION }}
120+
121+
- name: Setup BEAM
122+
uses: erlef/[email protected]
123+
with:
124+
otp-version: ${{ env.OTP_VERSION }}
125+
rebar3-version: ${{ env.REBAR_VERSION }}
126+
127+
- name: Cache _build
128+
uses: actions/cache@v2
129+
with:
130+
path: _build/*/lib
131+
key: ${{ runner.os }}-otp-${{ env.OTP_VERSION }}-build-${{ hashFiles('rebar.lock') }}
132+
restore-keys: |
133+
${{ runner.os }}-otp-${{ env.OTP_VERSION }}-build-
134+
135+
- name: Run EUnit
136+
run: rebar3 eunit --cover
137+
138+
- name: Run CT
139+
id: run-common-test
140+
run: rebar3 ct --cover
141+
142+
- name: Store CT Logs
143+
if: ${{ failure() && steps.run-common-test.outcome == 'failure' }}
144+
uses: actions/upload-artifact@v2
145+
with:
146+
name: ct-logs
147+
path: _build/test/logs
148+
149+
- name: Generate coverage reports
150+
run: rebar3 covertool generate
151+
152+
- name: Upload coverage reports
153+
uses: codecov/codecov-action@v2
154+
with:
155+
files: _build/test/covertool/*.covertool.xml

.gitmodules

Lines changed: 0 additions & 4 deletions
This file was deleted.

Jenkinsfile

Lines changed: 0 additions & 42 deletions
This file was deleted.

Makefile

Lines changed: 10 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,43 +1,19 @@
11
REBAR := $(shell which rebar3 2>/dev/null || which ./rebar3)
2-
SUBMODULES = build_utils
3-
SUBTARGETS = $(patsubst %,%/.git,$(SUBMODULES))
42

5-
UTILS_PATH := build_utils
6-
# ToDo: remove unused TEMPLATES_PATH here, when the bug
7-
# with handling of the varriable in build_utils is fixed
8-
TEMPLATES_PATH := .
9-
SERVICE_NAME := woody
3+
.PHONY: compile test xref lint check_format format clean distclean dialyze cover bench
104

11-
BUILD_IMAGE_NAME := build-erlang
12-
BUILD_IMAGE_TAG := c60896ef07d41e7ae2e5f9b6ce845a60ad79acc7
13-
14-
CALL_W_CONTAINER := all submodules compile xref lint test bench dialyze clean distclean \
15-
check_format format
16-
17-
.PHONY: $(CALL_W_CONTAINER)
18-
19-
all: compile
20-
21-
-include $(UTILS_PATH)/make_lib/utils_container.mk
22-
23-
$(SUBTARGETS): %/.git: %
24-
git submodule update --init $<
25-
touch $@
26-
27-
submodules: $(SUBTARGETS)
28-
29-
compile: submodules
5+
compile:
306
$(REBAR) compile
317

32-
test: submodules
8+
test:
339
$(REBAR) eunit
3410
$(REBAR) ct
3511

36-
xref: submodules
12+
xref:
3713
$(REBAR) xref
3814

39-
lint: compile
40-
elvis rock
15+
lint:
16+
$(REBAR) lint
4117

4218
check_format:
4319
$(REBAR) fmt -c
@@ -57,6 +33,10 @@ distclean:
5733
dialyze:
5834
$(REBAR) as test dialyzer
5935

36+
cover:
37+
$(REBAR) cover
38+
$(REBAR) covertool generate
39+
6040
bench:
6141
$(REBAR) as test bench -m bench_woody_event_handler -n 1000
6242
$(REBAR) as test bench -m bench_woody_formatter -n 10

README.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
Woody [![Build Status](http://ci.rbkmoney.com/buildStatus/icon?job=rbkmoney_private/woody_erlang/master)](http://ci.rbkmoney.com/job/rbkmoney_private/view/Erlang/job/woody_erlang/job/master/)
1+
Woody
22
======
33

4-
Erlang реализация [Библиотеки RPC вызовов для общения между микросервисами](http://coredocs.rbkmoney.com/design/ms/platform/rpc-lib/)
4+
Erlang реализация [Библиотеки RPC вызовов для общения между микросервисами](#coredocs/design/ms/platform/rpc-lib/)
55

66
версия требований: __ac4d40cc22d649d03369fcd52fb1230e51cdf52e__
77

@@ -58,7 +58,7 @@ Erlang реализация [Библиотеки RPC вызовов для об
5858

5959
В случае вызова _thrift_ `oneway` функции (_thrift_ реализация _cast_) `woody_client:call/3` вернет `{ok, ok}`.
6060

61-
Если сервер бросает `Exception`, описанный в _.thrift_ файле сервиса (т.е. _Бизнес ошибку_ в [терминологии](http://coredocs.rbkmoney.com/design/ms/platform/overview/#_7) макросервис платформы), `woody_client:call/3` вернет это исключение в виде: `{exception, Exception}`.
61+
Если сервер бросает `Exception`, описанный в _.thrift_ файле сервиса (т.е. _Бизнес ошибку_ в [терминологии](#coredocs/design/ms/platform/overview/#_7) макросервис платформы), `woody_client:call/3` вернет это исключение в виде: `{exception, Exception}`.
6262

6363
В случае получения _Системной_ ошибки клиент выбрасывает _erlang:error_ типа `{woody_error, woody_error:system_error()}`.
6464

@@ -74,7 +74,7 @@ Erlang реализация [Библиотеки RPC вызовов для об
7474
18> {ok, Result2} = woody_client:call(Request, Opts1, Context2).
7575
```
7676

77-
`Context` позволяет аннотировать RPC запросы дополнительными мета данными в виде _key-value_. `Context` передается только в запросах и изменение мета данных возможно только в режиме _append-only_ (т.е. на попытку переопределить уже существующую запись в `context meta`, библиотека вернет ошибку). Поскольку на транспортном уровне контекст передается в виде custom HTTP заголовков, синтаксис метаданных _key-value_ должен следовать ограничениям [RFC7230 ](https://tools.ietf.org/html/rfc7230#section-3.2.6). Размер ключа записи метаданных не должен превышать _53 байта_ (см. остальные требования к метаданным в [описании библиотеки](http://coredocs.rbkmoney.com/design/ms/platform/rpc-lib/#rpc_2)).
77+
`Context` позволяет аннотировать RPC запросы дополнительными мета данными в виде _key-value_. `Context` передается только в запросах и изменение мета данных возможно только в режиме _append-only_ (т.е. на попытку переопределить уже существующую запись в `context meta`, библиотека вернет ошибку). Поскольку на транспортном уровне контекст передается в виде custom HTTP заголовков, синтаксис метаданных _key-value_ должен следовать ограничениям [RFC7230 ](https://tools.ietf.org/html/rfc7230#section-3.2.6). Размер ключа записи метаданных не должен превышать _53 байта_ (см. остальные требования к метаданным в [описании библиотеки](#coredocs/design/ms/platform/rpc-lib/#rpc_2)).
7878

7979
```erlang
8080
19> Meta1 = #{<<"client1-name">> => <<"Vasya">>}.
@@ -87,7 +87,7 @@ Erlang реализация [Библиотеки RPC вызовов для об
8787
26> FullMeta = woody_context:get_meta(Context4).
8888
```
8989

90-
`Context` также позволяет задать [deadline](http://coredocs.rbkmoney.com/design/ms/platform/rpc-lib/#deadline) на исполнение запроса. Значение _deadline_ вложенных запросов можно менять произвольным образом. Также таймауты на запрос, [вычисляемые по deadline](src/woody_client_thrift_http_transport.erl), можно явно переопределить из приложения через _transport_opts_ в `woody_client:options()`. Модуль [woody_deadline](src/woody_deadline.erl) содержит API для работы с deadline.
90+
`Context` также позволяет задать [deadline](#coredocs/design/ms/platform/rpc-lib/#deadline) на исполнение запроса. Значение _deadline_ вложенных запросов можно менять произвольным образом. Также таймауты на запрос, [вычисляемые по deadline](src/woody_client_thrift_http_transport.erl), можно явно переопределить из приложения через _transport_opts_ в `woody_client:options()`. Модуль [woody_deadline](src/woody_deadline.erl) содержит API для работы с deadline.
9191

9292
```erlang
9393
27> Deadline = {{{2017, 12, 31}, {23, 59, 59}}, 350}.

build_utils

Lines changed: 0 additions & 1 deletion
This file was deleted.

0 commit comments

Comments
 (0)