Skip to content

Commit

Permalink
simplify stack
Browse files Browse the repository at this point in the history
  • Loading branch information
fogfish committed Nov 8, 2023
1 parent 884e378 commit b8d179d
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 9 deletions.
8 changes: 3 additions & 5 deletions broker/eventbridge/awscdk.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,14 @@ package eventbridge

import (
"os"
"strconv"

"github.com/aws/aws-cdk-go/awscdk/v2"
"github.com/aws/aws-cdk-go/awscdk/v2/awsevents"
"github.com/aws/aws-cdk-go/awscdk/v2/awseventstargets"
"github.com/aws/aws-cdk-go/awscdk/v2/awslambda"
"github.com/aws/constructs-go/constructs/v10"
"github.com/aws/jsii-runtime-go"
"github.com/fogfish/guid"
"github.com/fogfish/scud"
)

Expand Down Expand Up @@ -106,8 +106,7 @@ type ServerlessStackProps struct {

type ServerlessStack struct {
awscdk.Stack
bus awsevents.IEventBus
sinks []*Sink
bus awsevents.IEventBus
}

func NewServerlessStack(app awscdk.App, id *string, props *ServerlessStackProps) *ServerlessStack {
Expand Down Expand Up @@ -149,10 +148,9 @@ func (stack *ServerlessStack) NewSink(props *SinkProps) *Sink {

props.System = stack.bus

name := "Sink" + strconv.Itoa(len(stack.sinks))
name := "Sink" + guid.L.K(guid.Clock).String()
sink := NewSink(stack.Stack, jsii.String(name), props)

stack.sinks = append(stack.sinks, sink)
return sink
}

Expand Down
6 changes: 2 additions & 4 deletions broker/eventsqs/awscdk.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ package eventsqs

import (
"os"
"strconv"

"github.com/aws/aws-cdk-go/awscdk/v2"
"github.com/aws/aws-cdk-go/awscdk/v2/awslambda"
Expand All @@ -19,6 +18,7 @@ import (
"github.com/aws/constructs-go/constructs/v10"
"github.com/aws/jsii-runtime-go"

"github.com/fogfish/guid"
"github.com/fogfish/scud"
)

Expand Down Expand Up @@ -66,7 +66,6 @@ type ServerlessStackProps struct {
type ServerlessStack struct {
awscdk.Stack
queue awssqs.IQueue
sinks []*Sink
}

func NewServerlessStack(app awscdk.App, id *string, props *ServerlessStackProps) *ServerlessStack {
Expand Down Expand Up @@ -115,10 +114,9 @@ func (stack *ServerlessStack) NewSink(props *SinkProps) *Sink {

props.Queue = stack.queue

name := "Sink" + strconv.Itoa(len(stack.sinks))
name := "Sink" + guid.L.K(guid.Clock).String()
sink := NewSink(stack.Stack, jsii.String(name), props)

stack.sinks = append(stack.sinks, sink)
return sink
}

Expand Down

0 comments on commit b8d179d

Please sign in to comment.