Skip to content

Commit 70b5dca

Browse files
authored
Merge pull request #26 from kaleido-io/remove-topic
Remove the websocket.topic for simplicity and to avoid undefined behavior
2 parents f29dbad + 77129a9 commit 70b5dca

File tree

5 files changed

+6
-13
lines changed

5 files changed

+6
-13
lines changed

.vscode/settings.json

+1
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
"badurl",
1010
"blocklistener",
1111
"ccache",
12+
"Compat",
1213
"confirmationsmocks",
1314
"dataexchange",
1415
"Debugf",

internal/events/eventstream.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,7 @@ func (es *eventStream) initAction(startedState *startedStreamState) {
163163
case apitypes.EventStreamTypeWebhook:
164164
startedState.action = newWebhookAction(ctx, es.spec.Webhook).attemptBatch
165165
case apitypes.EventStreamTypeWebSocket:
166-
startedState.action = newWebSocketAction(es.wsChannels, es.spec.WebSocket, *es.spec.WebSocket.Topic).attemptBatch
166+
startedState.action = newWebSocketAction(es.wsChannels, es.spec.WebSocket, *es.spec.Name).attemptBatch
167167
default:
168168
// mergeValidateEsConfig always be called previous to this
169169
panic(i18n.NewError(ctx, tmmsgs.MsgInvalidStreamType, *es.spec.Type))
@@ -236,7 +236,7 @@ func mergeValidateEsConfig(ctx context.Context, base *apitypes.EventStream, upda
236236
changed = apitypes.CheckUpdateEnum(changed, &merged.Type, base.Type, updates.Type, apitypes.EventStreamTypeWebSocket)
237237
switch *merged.Type {
238238
case apitypes.EventStreamTypeWebSocket:
239-
if merged.WebSocket, changed, err = mergeValidateWsConfig(ctx, changed, *merged.Name, base.WebSocket, updates.WebSocket); err != nil {
239+
if merged.WebSocket, changed, err = mergeValidateWsConfig(ctx, changed, base.WebSocket, updates.WebSocket); err != nil {
240240
return nil, false, err
241241
}
242242
case apitypes.EventStreamTypeWebhook:

internal/events/eventstream_test.go

+2-6
Original file line numberDiff line numberDiff line change
@@ -135,10 +135,7 @@ func TestConfigNewDefaultsUpdate(t *testing.T) {
135135
InitDefaults()
136136

137137
es := testESConf(t, `{
138-
"name": "test1",
139-
"websocket": {
140-
"topic": "test1"
141-
}
138+
"name": "test1"
142139
}`)
143140
es, changed, err := mergeValidateEsConfig(context.Background(), nil, es)
144141
assert.NoError(t, err)
@@ -159,8 +156,7 @@ func TestConfigNewDefaultsUpdate(t *testing.T) {
159156
"suspended":false,
160157
"type":"websocket",
161158
"websocket": {
162-
"distributionMode":"load_balance",
163-
"topic":"test1"
159+
"distributionMode":"load_balance"
164160
}
165161
}`, string(b))
166162

internal/events/websockets.go

+1-4
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ import (
2626
"github.com/hyperledger/firefly-transaction-manager/pkg/apitypes"
2727
)
2828

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

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

50-
// Topic
51-
changed = apitypes.CheckUpdateString(changed, &merged.Topic, base.Topic, updates.Topic, esName /* default to the ES name */)
52-
5350
return merged, changed, nil
5451
}
5552

pkg/apitypes/api_types.go

-1
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,6 @@ type WebhookConfig struct {
9999

100100
type WebSocketConfig struct {
101101
DistributionMode *DistributionMode `ffstruct:"wsconfig" json:"distributionMode,omitempty"`
102-
Topic *string `ffstruct:"wsconfig" json:"topic,omitempty"`
103102
}
104103

105104
type Listener struct {

0 commit comments

Comments
 (0)