Skip to content

Commit

Permalink
feat: Close operator consumer when context is cancelled
Browse files Browse the repository at this point in the history
  • Loading branch information
Hyodar committed Feb 6, 2024
1 parent 0d756bb commit 39bbaf9
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions operator/operator.go
Original file line number Diff line number Diff line change
Expand Up @@ -290,6 +290,8 @@ func (o *Operator) Start(ctx context.Context) error {
for {
select {
case <-ctx.Done():
err = o.Close()
o.logger.Fatal("Error while closing", "err", err)
return nil
case err := <-metricsErrChan:
// TODO(samlaf); we should also register the service as unhealthy in the node api
Expand Down Expand Up @@ -327,6 +329,14 @@ func (o *Operator) Start(ctx context.Context) error {
}
}

func (o *Operator) Close() error {
if err := o.consumer.Close(); err != nil {
return err
}

return nil
}

// Takes a CheckpointTaskCreatedLog struct as input and returns a TaskResponseHeader struct.
// The TaskResponseHeader struct is the struct that is signed and sent to the contract as a task response.
func (o *Operator) ProcessCheckpointTaskCreatedLog(checkpointTaskCreatedLog *taskmanager.ContractSFFLTaskManagerCheckpointTaskCreated) *taskmanager.CheckpointTaskResponse {
Expand Down

0 comments on commit 39bbaf9

Please sign in to comment.