Skip to content

Commit

Permalink
payloads are pointers
Browse files Browse the repository at this point in the history
  • Loading branch information
drewbailey committed Dec 9, 2020
1 parent b908250 commit 2c34da4
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 12 deletions.
4 changes: 2 additions & 2 deletions nomad/state/events.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ func eventFromChange(change memdb.Change) (structs.Event, bool) {
return structs.Event{
Topic: structs.TopicACLPolicy,
Key: before.Name,
Payload: structs.ACLPolicyEvent{
Payload: &structs.ACLPolicyEvent{
ACLPolicy: before,
},
}, true
Expand Down Expand Up @@ -121,7 +121,7 @@ func eventFromChange(change memdb.Change) (structs.Event, bool) {
return structs.Event{
Topic: structs.TopicACLPolicy,
Key: after.Name,
Payload: structs.ACLPolicyEvent{
Payload: &structs.ACLPolicyEvent{
ACLPolicy: after,
},
}, true
Expand Down
4 changes: 2 additions & 2 deletions nomad/stream/event_broker.go
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ func (e *EventBroker) handleACLUpdates(ctx context.Context) {
return
case update := <-e.aclCh:
switch payload := update.Payload.(type) {
case structs.ACLTokenEvent:
case *structs.ACLTokenEvent:
tokenSecretID := payload.SecretID()

// Token was deleted
Expand All @@ -213,7 +213,7 @@ func (e *EventBroker) handleACLUpdates(ctx context.Context) {
return !aclAllowsSubscription(aclObj, sub.req)
})

case structs.ACLPolicyEvent:
case *structs.ACLPolicyEvent:
// Re-evaluate each subscriptions permissions since a policy
// change may or may not affect the subscription
e.checkSubscriptionsAgainstPolicyChange()
Expand Down
12 changes: 4 additions & 8 deletions nomad/stream/event_broker_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ func TestEventBroker_EmptyReqToken_DistinctSubscriptions(t *testing.T) {
require.Equal(t, subscriptionStateOpen, atomic.LoadUint32(&sub2.state))
}

func TestEventBroker_handleACLUpdates_tokendeleted(t *testing.T) {
func TestEventBroker_handleACLUpdates_TokenDeleted(t *testing.T) {
ctx, cancel := context.WithCancel(context.Background())
t.Cleanup(cancel)

Expand All @@ -133,13 +133,9 @@ func TestEventBroker_handleACLUpdates_tokendeleted(t *testing.T) {
defer sub1.Unsubscribe()

aclEvent := structs.Event{
Topic: structs.TopicACLToken,
Type: structs.TypeACLTokenDeleted,
Payload: structs.ACLTokenEvent{
ACLToken: &structs.ACLToken{
SecretID: "foo",
},
},
Topic: structs.TopicACLToken,
Type: structs.TypeACLTokenDeleted,
Payload: structs.NewACLTokenEvent("foo", &structs.ACLToken{}),
}

publisher.Publish(&structs.Events{Index: 100, Events: []structs.Event{aclEvent}})
Expand Down

0 comments on commit 2c34da4

Please sign in to comment.