Skip to content

Commit

Permalink
Merge pull request #26 from kaleido-io/remove-topic
Browse files Browse the repository at this point in the history
Remove the websocket.topic for simplicity and to avoid undefined behavior
  • Loading branch information
nguyer authored Aug 23, 2022
2 parents f29dbad + 77129a9 commit 70b5dca
Show file tree
Hide file tree
Showing 5 changed files with 6 additions and 13 deletions.
1 change: 1 addition & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
"badurl",
"blocklistener",
"ccache",
"Compat",
"confirmationsmocks",
"dataexchange",
"Debugf",
Expand Down
4 changes: 2 additions & 2 deletions internal/events/eventstream.go
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ func (es *eventStream) initAction(startedState *startedStreamState) {
case apitypes.EventStreamTypeWebhook:
startedState.action = newWebhookAction(ctx, es.spec.Webhook).attemptBatch
case apitypes.EventStreamTypeWebSocket:
startedState.action = newWebSocketAction(es.wsChannels, es.spec.WebSocket, *es.spec.WebSocket.Topic).attemptBatch
startedState.action = newWebSocketAction(es.wsChannels, es.spec.WebSocket, *es.spec.Name).attemptBatch
default:
// mergeValidateEsConfig always be called previous to this
panic(i18n.NewError(ctx, tmmsgs.MsgInvalidStreamType, *es.spec.Type))
Expand Down Expand Up @@ -236,7 +236,7 @@ func mergeValidateEsConfig(ctx context.Context, base *apitypes.EventStream, upda
changed = apitypes.CheckUpdateEnum(changed, &merged.Type, base.Type, updates.Type, apitypes.EventStreamTypeWebSocket)
switch *merged.Type {
case apitypes.EventStreamTypeWebSocket:
if merged.WebSocket, changed, err = mergeValidateWsConfig(ctx, changed, *merged.Name, base.WebSocket, updates.WebSocket); err != nil {
if merged.WebSocket, changed, err = mergeValidateWsConfig(ctx, changed, base.WebSocket, updates.WebSocket); err != nil {
return nil, false, err
}
case apitypes.EventStreamTypeWebhook:
Expand Down
8 changes: 2 additions & 6 deletions internal/events/eventstream_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -135,10 +135,7 @@ func TestConfigNewDefaultsUpdate(t *testing.T) {
InitDefaults()

es := testESConf(t, `{
"name": "test1",
"websocket": {
"topic": "test1"
}
"name": "test1"
}`)
es, changed, err := mergeValidateEsConfig(context.Background(), nil, es)
assert.NoError(t, err)
Expand All @@ -159,8 +156,7 @@ func TestConfigNewDefaultsUpdate(t *testing.T) {
"suspended":false,
"type":"websocket",
"websocket": {
"distributionMode":"load_balance",
"topic":"test1"
"distributionMode":"load_balance"
}
}`, string(b))

Expand Down
5 changes: 1 addition & 4 deletions internal/events/websockets.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import (
"github.com/hyperledger/firefly-transaction-manager/pkg/apitypes"
)

func mergeValidateWsConfig(ctx context.Context, changed bool, esName string, base *apitypes.WebSocketConfig, updates *apitypes.WebSocketConfig) (*apitypes.WebSocketConfig, bool, error) {
func mergeValidateWsConfig(ctx context.Context, changed bool, base *apitypes.WebSocketConfig, updates *apitypes.WebSocketConfig) (*apitypes.WebSocketConfig, bool, error) {

if base == nil {
base = &apitypes.WebSocketConfig{}
Expand All @@ -47,9 +47,6 @@ func mergeValidateWsConfig(ctx context.Context, changed bool, esName string, bas
return nil, false, i18n.NewError(ctx, tmmsgs.MsgInvalidDistributionMode, *merged.DistributionMode)
}

// Topic
changed = apitypes.CheckUpdateString(changed, &merged.Topic, base.Topic, updates.Topic, esName /* default to the ES name */)

return merged, changed, nil
}

Expand Down
1 change: 0 additions & 1 deletion pkg/apitypes/api_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,6 @@ type WebhookConfig struct {

type WebSocketConfig struct {
DistributionMode *DistributionMode `ffstruct:"wsconfig" json:"distributionMode,omitempty"`
Topic *string `ffstruct:"wsconfig" json:"topic,omitempty"`
}

type Listener struct {
Expand Down

0 comments on commit 70b5dca

Please sign in to comment.