Skip to content

Commit

Permalink
Merge pull request #774 from multiversx/notifier-ws-integration-updates
Browse files Browse the repository at this point in the history
Update notifier ws integration notes
  • Loading branch information
ssd04 authored Dec 21, 2023
2 parents 7128334 + 2dd7028 commit 620459d
Showing 1 changed file with 56 additions and 13 deletions.
69 changes: 56 additions & 13 deletions docs/sdk-and-tools/notifier.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,11 @@ In the figure above:
- Notifier will push events to RabbitMQ if enabled, or via Websocket. If Websocket will be enabled an additional endpoint will be available:
- `/hub/ws` (GET) - this route can be used to manage the websocket connection subscription

:::info
Please make the distinction between `observer node` -> `notifier` communication (which can be via HTTP or WebSocket) and
`notifier` -> `subscriber` (which can be via RabbitMQ and WebSocket).
:::

[comment]: # (mx-context-auto)

## Set up observer and notifier
Expand All @@ -63,7 +68,7 @@ The WebSocket integration is a generic one, and can be used for multiple outport
In case Elasticsearch integration is already being used with WebSocket connector, a separate config
section `HostDriversConfig` has to be set for event notifier.

The corresponding config section for enabling the driver:
The corresponding config section for enabling the WebSocket driver on observer node:

```toml
[[HostDriversConfig]]
Expand Down Expand Up @@ -119,7 +124,7 @@ For http integration, the supported config variables are as follows:
- `Username`: the username used for authorization, if enabled.
- `Password`: the password used for authorization, if enabled.

The corresponding config section for enabling the driver:
The corresponding config section for enabling the driver on observer node:

```toml
[EventNotifierConnector]
Expand All @@ -139,6 +144,13 @@ The corresponding config section for enabling the driver:

# Password is used to authorize an observer to push event data
Password = ""

# RequestTimeoutSec defines the timeout in seconds for the http client
RequestTimeoutSec = 60

# MarshallerType is used to define the marshaller type to be used for inner
# marshalled structures in block events data
MarshallerType = "json"
```

:::info
Expand All @@ -160,6 +172,33 @@ delays due to outport driver.
In the notifier configuration directory (`cmd/notifier/config`), there is the `config.toml`
file that can be used to configure the service.

There are some general configuration options, which should be fine with their default values:
```toml
[General]
# ExternalMarshaller is used for handling incoming/outcoming api requests
[General.ExternalMarshaller]
Type = "json"
# InternalMarshaller is used for handling internal structs
# This has to be mapped with the internal marshalling used for notifier outport driver
[General.InternalMarshaller]
Type = "json"

# Address pubkey converter config options
[General.AddressConverter]
Type = "bech32"
Prefix = "erd"
Length = 32

# CheckDuplicates signals if the events received from observers have been already pushed to clients
# Requires a redis instance/cluster and should be used when multiple observers push from the same shard
CheckDuplicates = true
```

:::info
Starting with release `v1.2.0`, `CheckDuplicates` field has been moved from `ConnectorApi` section to
the newly added `General` section.
:::

There are 2 ways to connect observer node with events notifier service:
- via WebSocket integration
- via HTTP integration (which will be deprecated in the future)
Expand Down Expand Up @@ -204,29 +243,33 @@ There is a separate config section `WebSocketConnector` that has to be aligned w
#### HTTP Integration

The supported config variables are:
- `Port`: the port on which the http server listens on. Should be the same
as the port in the `ProxyUrl` described above.
- `Host`: the address and/or port on which the http server listens on. Should be the same
port in the `ProxyUrl` described above, for observer node.
- `Username`: the username used to authorize an observer. Can be left empty for `UseAuthorization = false`.
- `Password`: the password used to authorize an observer. Can be left empty for `UseAuthorization = false`.
- `CheckDuplicates`: if true, it will check (based on a locker service using redis) if the event have been already pushed to clients

The `ConnectorApi` section has to be aligned with the one from observer node:
```toml
[ConnectorApi]
# The port on which the Hub listens for subscriptions
Port = "5000"
# Enabled will determine if http connector will be enabled or not
Enabled = true

# The address on which the events notifier listens for subscriptions
# It can be specified as "localhost:5000" or only as "5000"
Host = "5000"

# Username is the username needed to authorize an observer to push data
# Username and Password needed to authorize the connector
# BasicAuth is enabled only for the endpoints with "Auth" flag enabled
# in api.toml config file
Username = ""

# Password is the password needed to authorize an observer to push event data
Password = ""

# CheckDuplicates signals if the events received from observers have been already pushed to clients
# Requires a redis instance/cluster and should be used when multiple observers push from the same shard
CheckDuplicates = true
```

:::info
Starting with release `v1.2.0`, an additional field `Enabled = true` has been added.
:::

[comment]: # (mx-context-auto)

#### Deduplication
Expand Down

0 comments on commit 620459d

Please sign in to comment.