Skip to content

Commit

Permalink
chore: apply context to bridge controller (#43)
Browse files Browse the repository at this point in the history
  • Loading branch information
DNK90 committed Nov 23, 2023
1 parent 7897f76 commit 4ea6821
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,14 +57,17 @@ type Controller struct {
}

func New(cfg *Config, db *gorm.DB, helpers utils.Utils) (*Controller, error) {
return NewWithContext(context.Background(), cfg, db, helpers)
}

func NewWithContext(ctx context.Context, cfg *Config, db *gorm.DB, helpers utils.Utils) (*Controller, error) {
if cfg.NumberOfWorkers <= 0 {
cfg.NumberOfWorkers = defaultWorkers
}

ctx, cancel := context.WithCancel(context.Background())
newCtx, cancel := context.WithCancel(ctx)
c := &Controller{
cfg: cfg,
ctx: ctx,
ctx: newCtx,
cancelFunc: cancel,
listeners: make(map[string]Listener),
HandlerABIs: make(map[string]*abi.ABI),
Expand Down

0 comments on commit 4ea6821

Please sign in to comment.