Skip to content

Commit d5df3cc

Browse files
authored
refactor TriggerBatch's Event.Data str->interface (#50)
- it refactors TriggerBatch's API regarding Event.Data to be consistent with the Trigger's API , moving from a `string` type to a `interface{}` type. This allows any matching type to be passed in as a Payload.
1 parent fd1aae4 commit d5df3cc

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

event.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,10 @@ import (
1010
const maxEventPayloadSize = 10240
1111

1212
type Event struct {
13-
Channel string `json:"channel"`
14-
Name string `json:"name"`
15-
Data string `json:"data"`
16-
SocketId *string `json:"socket_id,omitempty"`
13+
Channel string `json:"channel"`
14+
Name string `json:"name"`
15+
Data interface{} `json:"data"`
16+
SocketId *string `json:"socket_id,omitempty"`
1717
}
1818

1919
type eventPayload struct {
@@ -60,7 +60,7 @@ func createTriggerBatchPayload(batch []Event, encryptionKey string) ([]byte, err
6060
} else {
6161
batch[idx].Data = string(dataBytes)
6262
}
63-
if len(batch[idx].Data) > maxEventPayloadSize {
63+
if len(batch[idx].Data.(string)) > maxEventPayloadSize {
6464
return nil, fmt.Errorf("Data of the event #%d in batch, must be smaller than 10kb", idx)
6565
}
6666
}

0 commit comments

Comments
 (0)