Skip to content

Commit

Permalink
Merge pull request #33 from formancehq/chore/merge-2-workers-in-one
Browse files Browse the repository at this point in the history
chore: merge 2 workers in one
  • Loading branch information
flemzord committed Dec 9, 2022
2 parents afca2ec + 3d6119d commit 672e039
Show file tree
Hide file tree
Showing 37 changed files with 1,274 additions and 1,392 deletions.
13 changes: 5 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,7 @@ A user config is made of the following information:
The service has 3 starting modes, split into 3 separate commands:

- `server`: REST web service API managing webhooks configs for users.
- `worker messages`: background service consuming kafka events on selected topics and sending webhooks based on user configs.
- `worker retries`: background service periodically finding failed webhooks requests to retry and sending new attempts.
- `worker`: background service consuming kafka events on selected topics to send webhooks based on user configs and periodically finding failed webhooks requests to retry and sending new attempts.

## Run the stack locally
```
Expand Down Expand Up @@ -50,16 +49,14 @@ Available Commands:
help Help about any command
version Get webhooks version
server Start webhooks server
worker messages Start webhooks worker messages
worker retries Start webhooks worker retries
worker Start webhooks worker
Flags:
-h, --help help for webhooks
--http-bind-address-server string server HTTP bind address (default ":8080")
--http-bind-address-worker-messages string worker messsages HTTP bind address (default ":8081")
--http-bind-address-worker-retries string worker retries HTTP bind address (default ":8082")
--retry-schedule durations worker retries schedule (default [1m,5m,30m,5h,24h])
--retry-cron duration worker retries cron (default 1m)
--http-bind-address-worker string worker HTTP bind address (default ":8081")
--retries-schedule durations worker retry schedule (default [1m,5m,30m,5h,24h])
--retries-cron duration worker retry cron (default 1m)
--kafka-brokers strings Kafka brokers (default [localhost:9092])
--kafka-consumer-group string Kafka consumer group (default "webhooks")
--kafka-password string Kafka password
Expand Down
12 changes: 11 additions & 1 deletion Taskfile.yml
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ tasks:
docker:
cmds:
- docker compose up -d --remove-orphans mongo redpanda redpanda-config redpanda-ui
- docker compose up -d --remove-orphans postgres redpanda redpanda-config redpanda-ui

coverage:
cmds:
Expand All @@ -72,3 +72,13 @@ tasks:
run: once
cmds:
- docker build -t numary:{{.SERVICE}}-{{.APP_SHA}} --target app --build-arg APP_SHA={{.APP_SHA}} --build-arg APP_VERSION={{.APP_VERSION}} .

stop:
cmds:
- docker-compose stop
rm:
deps:
- stop
cmds:
- docker-compose rm -f
- docker volume prune -f
42 changes: 25 additions & 17 deletions client/api/openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -241,30 +241,30 @@ components:
ConfigResponse:
example:
data:
createdAt: 2022-07-20T07:31:40Z
createdAt: 2000-01-23T04:56:07.000+00:00
endpoint: https://example.com
modifiedAt: 2022-07-20T08:32:59Z
active: true
id: 046b6c7f-0b8a-43b9-b35d-6489e6daee91
secret: V0bivxRWveaoz08afqjU6Ko/jwO0Cb+3
eventTypes:
- TYPE1
- TYPE2
updatedAt: 2000-01-23T04:56:07.000+00:00
properties:
data:
$ref: '#/components/schemas/Config'
type: object
Config:
example:
createdAt: 2022-07-20T07:31:40Z
createdAt: 2000-01-23T04:56:07.000+00:00
endpoint: https://example.com
modifiedAt: 2022-07-20T08:32:59Z
active: true
id: 046b6c7f-0b8a-43b9-b35d-6489e6daee91
secret: V0bivxRWveaoz08afqjU6Ko/jwO0Cb+3
eventTypes:
- TYPE1
- TYPE2
updatedAt: 2000-01-23T04:56:07.000+00:00
properties:
id:
format: uuid
Expand All @@ -287,31 +287,31 @@ components:
example: true
type: boolean
createdAt:
example: 2022-07-20T07:31:40Z
format: date-time
type: string
modifiedAt:
example: 2022-07-20T08:32:59Z
updatedAt:
format: date-time
type: string
AttemptResponse:
example:
data:
date: 2000-01-23T04:56:07.000+00:00
nextRetryAfter: 2000-01-23T04:56:07.000+00:00
webhookID: 4997257d-dfb6-445b-929c-cbe2ab182818
createdAt: 2000-01-23T04:56:07.000+00:00
webhookID: 046b6c7f-0b8a-43b9-b35d-6489e6daee91
payload: "{\"data\":\"test\"}"
id: 046b6c7f-0b8a-43b9-b35d-6489e6daee91
retryAttempt: 1
config:
createdAt: 2022-07-20T07:31:40Z
createdAt: 2000-01-23T04:56:07.000+00:00
endpoint: https://example.com
modifiedAt: 2022-07-20T08:32:59Z
active: true
id: 046b6c7f-0b8a-43b9-b35d-6489e6daee91
secret: V0bivxRWveaoz08afqjU6Ko/jwO0Cb+3
eventTypes:
- TYPE1
- TYPE2
updatedAt: 2000-01-23T04:56:07.000+00:00
updatedAt: 2000-01-23T04:56:07.000+00:00
statusCode: 200
status: success
properties:
Expand All @@ -320,28 +320,36 @@ components:
type: object
Attempt:
example:
date: 2000-01-23T04:56:07.000+00:00
nextRetryAfter: 2000-01-23T04:56:07.000+00:00
webhookID: 4997257d-dfb6-445b-929c-cbe2ab182818
createdAt: 2000-01-23T04:56:07.000+00:00
webhookID: 046b6c7f-0b8a-43b9-b35d-6489e6daee91
payload: "{\"data\":\"test\"}"
id: 046b6c7f-0b8a-43b9-b35d-6489e6daee91
retryAttempt: 1
config:
createdAt: 2022-07-20T07:31:40Z
createdAt: 2000-01-23T04:56:07.000+00:00
endpoint: https://example.com
modifiedAt: 2022-07-20T08:32:59Z
active: true
id: 046b6c7f-0b8a-43b9-b35d-6489e6daee91
secret: V0bivxRWveaoz08afqjU6Ko/jwO0Cb+3
eventTypes:
- TYPE1
- TYPE2
updatedAt: 2000-01-23T04:56:07.000+00:00
updatedAt: 2000-01-23T04:56:07.000+00:00
statusCode: 200
status: success
properties:
id:
format: uuid
type: string
webhookID:
example: 4997257d-dfb6-445b-929c-cbe2ab182818
format: uuid
type: string
createdAt:
format: date-time
type: string
date:
updatedAt:
format: date-time
type: string
config:
Expand Down
78 changes: 65 additions & 13 deletions client/docs/Attempt.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,10 @@

Name | Type | Description | Notes
------------ | ------------- | ------------- | -------------
**Id** | Pointer to **string** | | [optional]
**WebhookID** | Pointer to **string** | | [optional]
**Date** | Pointer to **time.Time** | | [optional]
**CreatedAt** | Pointer to **time.Time** | | [optional]
**UpdatedAt** | Pointer to **time.Time** | | [optional]
**Config** | Pointer to [**Config**](Config.md) | | [optional]
**Payload** | Pointer to **string** | | [optional]
**StatusCode** | Pointer to **int32** | | [optional]
Expand All @@ -32,6 +34,31 @@ NewAttemptWithDefaults instantiates a new Attempt object
This constructor will only assign default values to properties that have it defined,
but it doesn't guarantee that properties required by API are set

### GetId

`func (o *Attempt) GetId() string`

GetId returns the Id field if non-nil, zero value otherwise.

### GetIdOk

`func (o *Attempt) GetIdOk() (*string, bool)`

GetIdOk returns a tuple with the Id field if it's non-nil, zero value otherwise
and a boolean to check if the value has been set.

### SetId

`func (o *Attempt) SetId(v string)`

SetId sets Id field to given value.

### HasId

`func (o *Attempt) HasId() bool`

HasId returns a boolean if a field has been set.

### GetWebhookID

`func (o *Attempt) GetWebhookID() string`
Expand All @@ -57,30 +84,55 @@ SetWebhookID sets WebhookID field to given value.

HasWebhookID returns a boolean if a field has been set.

### GetDate
### GetCreatedAt

`func (o *Attempt) GetCreatedAt() time.Time`

GetCreatedAt returns the CreatedAt field if non-nil, zero value otherwise.

### GetCreatedAtOk

`func (o *Attempt) GetCreatedAtOk() (*time.Time, bool)`

GetCreatedAtOk returns a tuple with the CreatedAt field if it's non-nil, zero value otherwise
and a boolean to check if the value has been set.

### SetCreatedAt

`func (o *Attempt) SetCreatedAt(v time.Time)`

SetCreatedAt sets CreatedAt field to given value.

### HasCreatedAt

`func (o *Attempt) HasCreatedAt() bool`

HasCreatedAt returns a boolean if a field has been set.

### GetUpdatedAt

`func (o *Attempt) GetDate() time.Time`
`func (o *Attempt) GetUpdatedAt() time.Time`

GetDate returns the Date field if non-nil, zero value otherwise.
GetUpdatedAt returns the UpdatedAt field if non-nil, zero value otherwise.

### GetDateOk
### GetUpdatedAtOk

`func (o *Attempt) GetDateOk() (*time.Time, bool)`
`func (o *Attempt) GetUpdatedAtOk() (*time.Time, bool)`

GetDateOk returns a tuple with the Date field if it's non-nil, zero value otherwise
GetUpdatedAtOk returns a tuple with the UpdatedAt field if it's non-nil, zero value otherwise
and a boolean to check if the value has been set.

### SetDate
### SetUpdatedAt

`func (o *Attempt) SetDate(v time.Time)`
`func (o *Attempt) SetUpdatedAt(v time.Time)`

SetDate sets Date field to given value.
SetUpdatedAt sets UpdatedAt field to given value.

### HasDate
### HasUpdatedAt

`func (o *Attempt) HasDate() bool`
`func (o *Attempt) HasUpdatedAt() bool`

HasDate returns a boolean if a field has been set.
HasUpdatedAt returns a boolean if a field has been set.

### GetConfig

Expand Down
26 changes: 13 additions & 13 deletions client/docs/Config.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ Name | Type | Description | Notes
**EventTypes** | Pointer to **[]string** | | [optional]
**Active** | Pointer to **bool** | | [optional]
**CreatedAt** | Pointer to **time.Time** | | [optional]
**ModifiedAt** | Pointer to **time.Time** | | [optional]
**UpdatedAt** | Pointer to **time.Time** | | [optional]

## Methods

Expand Down Expand Up @@ -181,30 +181,30 @@ SetCreatedAt sets CreatedAt field to given value.

HasCreatedAt returns a boolean if a field has been set.

### GetModifiedAt
### GetUpdatedAt

`func (o *Config) GetModifiedAt() time.Time`
`func (o *Config) GetUpdatedAt() time.Time`

GetModifiedAt returns the ModifiedAt field if non-nil, zero value otherwise.
GetUpdatedAt returns the UpdatedAt field if non-nil, zero value otherwise.

### GetModifiedAtOk
### GetUpdatedAtOk

`func (o *Config) GetModifiedAtOk() (*time.Time, bool)`
`func (o *Config) GetUpdatedAtOk() (*time.Time, bool)`

GetModifiedAtOk returns a tuple with the ModifiedAt field if it's non-nil, zero value otherwise
GetUpdatedAtOk returns a tuple with the UpdatedAt field if it's non-nil, zero value otherwise
and a boolean to check if the value has been set.

### SetModifiedAt
### SetUpdatedAt

`func (o *Config) SetModifiedAt(v time.Time)`
`func (o *Config) SetUpdatedAt(v time.Time)`

SetModifiedAt sets ModifiedAt field to given value.
SetUpdatedAt sets UpdatedAt field to given value.

### HasModifiedAt
### HasUpdatedAt

`func (o *Config) HasModifiedAt() bool`
`func (o *Config) HasUpdatedAt() bool`

HasModifiedAt returns a boolean if a field has been set.
HasUpdatedAt returns a boolean if a field has been set.


[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)
Expand Down
Loading

0 comments on commit 672e039

Please sign in to comment.