Skip to content

Commit

Permalink
set context method
Browse files Browse the repository at this point in the history
  • Loading branch information
SyntaxErrorLineNULL committed Aug 17, 2024
1 parent 981b369 commit 5a938d5
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions worker/worker.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,3 +33,17 @@ func NewWorker(workerID int64) *Worker {
logger: logger,
}
}

// SetContext sets the context for the worker. This method is used to provide
// a new context for the worker, which can be used to control its operations
// and manage its lifecycle. The method ensures that the provided context is not
// nil before setting it, maintaining the integrity of the worker's context.
func (w *Worker) SetContext(ctx context.Context) {
// Check if the provided context is not nil.
// This ensures that we only set a valid context for the worker.
if ctx != nil {
// Set the worker's context to the provided context.
// This allows the worker to use the new context for its operations.
w.workerContext = ctx
}
}

0 comments on commit 5a938d5

Please sign in to comment.