Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func WithContext ¶
WithContext allows setting a custom context for the supervisor, which can be used to control cancellation and timeouts for the supervised tasks.
func WithPolicy ¶
WithPolicy allows setting a custom policy for the supervisor, which can be used to control the behavior of the supervised tasks.
func WithStackProvider ¶
WithStackProvider allows setting a custom stack provider for the supervisor, which can be used to customize how stack traces are captured and formatted when a task panics.
func WithWriter ¶
WithWriter allows setting a custom writer for the supervisor, which can be used to redirect logs and output from the supervised tasks.
Types ¶
type Supervisor ¶
type Supervisor struct {
// contains filtered or unexported fields
}
Supervisor manages the execution of a Task according to a specified Policy. It handles task restarts based on the outcome of the task and the rules defined in the Policy.
func New ¶
func New(name string, opts ...option) *Supervisor
New creates a new Supervisor with the given name and options. The name is used for logging purposes, while the options allow customization of the supervisor's behavior, such as setting a custom context, policy, writer, or stack provider.
func (*Supervisor) Run ¶
func (s *Supervisor) Run(task Task) error
Run executes the provided Task under the supervision of the Supervisor. It will handle task restarts based on the outcome of the task and the rules defined in the Policy. The method will continue to restart the task according to the policy until the context is cancelled or the restart limit is exceeded.