Documentation
¶
Overview ¶
Package agent provides context management for the Alpamon agent.
Index ¶
- type ContextManager
- func (m *ContextManager) IsShutdown() bool
- func (m *ContextManager) NewContext(timeout time.Duration) (context.Context, context.CancelFunc)
- func (m *ContextManager) NewContextWithDeadline(deadline time.Time) (context.Context, context.CancelFunc)
- func (m *ContextManager) Root() context.Context
- func (m *ContextManager) Shutdown()
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ContextManager ¶
type ContextManager struct {
// contains filtered or unexported fields
}
ContextManager manages contexts for the agent, providing centralized context creation and cancellation.
func NewContextManager ¶
func NewContextManager() *ContextManager
NewContextManager creates a new context manager with a root context.
func (*ContextManager) IsShutdown ¶
func (m *ContextManager) IsShutdown() bool
IsShutdown returns true if the context manager has been shut down.
func (*ContextManager) NewContext ¶
func (m *ContextManager) NewContext(timeout time.Duration) (context.Context, context.CancelFunc)
NewContext creates a new child context with an optional timeout. If timeout is 0 or negative, no timeout is applied.
func (*ContextManager) NewContextWithDeadline ¶
func (m *ContextManager) NewContextWithDeadline(deadline time.Time) (context.Context, context.CancelFunc)
NewContextWithDeadline creates a new child context with a specific deadline.
func (*ContextManager) Root ¶
func (m *ContextManager) Root() context.Context
Root returns the root context. This should be used sparingly, primarily for operations that need to outlive the normal shutdown process.
func (*ContextManager) Shutdown ¶
func (m *ContextManager) Shutdown()
Shutdown cancels the root context, triggering cancellation of all child contexts. This should be called during graceful shutdown.