Skip to content

Commit

Permalink
use camel case format for websocket config
Browse files Browse the repository at this point in the history
  • Loading branch information
ssd04 committed Mar 20, 2024
1 parent 4f38d98 commit b6915da
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 25 deletions.
22 changes: 12 additions & 10 deletions cmd/connector/config/config.toml
Original file line number Diff line number Diff line change
@@ -1,30 +1,32 @@
[web_socket]
[WebSocket]
# IP with port used to recieve data via ws. Should be compatible with the one from node. See [HostDriverConfig].URL
# from https://github.com/multiversx/mx-chain-go/blob/master/cmd/node/config/external.toml.
url = "localhost:22111"
URL = "localhost:22111"

# Possible values: json, gogo protobuf. Should be compatible with [HostDriverConfig].MarshallerType
marshaller_type = "gogo protobuf"
MarshallerType = "gogo protobuf"

# This flag describes the mode to start the WebSocket connector. Can be "client" or "server"
mode = "server"
Mode = "server"

# Retry duration (receive/send data/acknowledge) in seconds
retry_duration = 5
RetryDurationInSec = 5

# This flag specifies if we should send an acknowledge signal upon recieving data
with_acknowledge = true
WithAcknowledge = true

# The duration in seconds to wait for an acknowledgement message
acknowledge_timeout_in_sec = 5
AcknowledgeTimeoutInSec = 5

# Signals if in case of data payload processing error, we should send the ack signal or not. If you want to block
# incoming data in case of a local error, this should be set to true.
blocking_ack_on_error = true
BlockingAckOnError = true

# This flag specifies if we should drop messages if there is no connection to the host
drop_messages_if_no_connection = false
version = 1
DropMessagesIfNoConnection = false

# Version specifies payload version (default = 1)
Version = 1

[DataPool]
NumberOfShards = 3
Expand Down
2 changes: 1 addition & 1 deletion cmd/connector/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ func startConnector(ctx *cli.Context) error {
return fmt.Errorf("cannot create ws firehose data processor, error: %w", err)
}

wsClient, err := factory.CreateWSConnector(cfg.WebSocketConfig, dataProcessor)
wsClient, err := factory.CreateWSConnector(cfg.WebSocket, dataProcessor)
if err != nil {
return fmt.Errorf("cannot create ws firehose connector, error: %w", err)
}
Expand Down
22 changes: 11 additions & 11 deletions config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,22 @@ package config

// Config holds general configuration
type Config struct {
WebSocketConfig WebSocketConfig `toml:"web_socket"`
DataPoolConfig DataPoolConfig
WebSocket WebSocketConfig
DataPool DataPoolConfig
OutportBlocksStorage StorageConfig
}

// WebSocketConfig holds web sockets config
type WebSocketConfig struct {
Url string `toml:"url"`
MarshallerType string `toml:"marshaller_type"`
Mode string `toml:"mode"`
RetryDuration uint32 `toml:"retry_duration"`
WithAcknowledge bool `toml:"with_acknowledge"`
AcknowledgeTimeoutInSec int `toml:"acknowledge_timeout_in_sec"`
BlockingAckOnError bool `toml:"blocking_ack_on_error"`
DropMessagesIfNoConnection bool `toml:"drop_messages_if_no_connection"` // Set to `true` to drop messages if there is no active WebSocket connection to send to.
Version uint32 `toml:"version"` // Defines the payload version.
URL string
MarshallerType string
Mode string
RetryDurationInSec uint32
WithAcknowledge bool
AcknowledgeTimeoutInSec int
BlockingAckOnError bool
DropMessagesIfNoConnection bool
Version uint32
}

// DataPoolConfig will map data poil configuration
Expand Down
2 changes: 1 addition & 1 deletion factory/dataProcessorFactory.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ func CreateDataProcessor(cfg config.Config) (websocket.PayloadHandler, error) {
return nil, err
}

blocksPool, err := process.NewBlocksPool(storageUnit, protoMarshaller, cfg.DataPoolConfig.NumberOfShards, cfg.DataPoolConfig.MaxDelta)
blocksPool, err := process.NewBlocksPool(storageUnit, protoMarshaller, cfg.DataPool.NumberOfShards, cfg.DataPool.MaxDelta)
if err != nil {
return nil, err
}
Expand Down
4 changes: 2 additions & 2 deletions factory/wsConnectorFactory.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,10 @@ func CreateWSConnector(cfg config.WebSocketConfig, dataProcessor websocket.Paylo
func createWsHost(wsMarshaller marshal.Marshalizer, cfg config.WebSocketConfig) (factoryHost.FullDuplexHost, error) {
return factoryHost.CreateWebSocketHost(factoryHost.ArgsWebSocketHost{
WebSocketConfig: data.WebSocketConfig{
URL: cfg.Url,
URL: cfg.URL,
WithAcknowledge: cfg.WithAcknowledge,
Mode: cfg.Mode,
RetryDurationInSec: int(cfg.RetryDuration),
RetryDurationInSec: int(cfg.RetryDurationInSec),
BlockingAckOnError: cfg.BlockingAckOnError,
DropMessagesIfNoConnection: cfg.DropMessagesIfNoConnection,
AcknowledgeTimeoutInSec: cfg.AcknowledgeTimeoutInSec,
Expand Down

0 comments on commit b6915da

Please sign in to comment.