Documentation
¶
Overview ¶
Package wlcontext provides custom error types for context-related operations.
Index ¶
Constants ¶
const RequestDoerKey = "doer"
RequestDoerKey is the context key used to store the user making a request.
const WgKey = "wg"
WgKey is the context key used to store a WaitGroup for coordinating goroutines.
Variables ¶
var ToZ func(c context.Context) Z
ToZ converts a context.Context to a ContextZ, panicking if the conversion fails.
Functions ¶
func NewCanceledError ¶
NewCanceledError creates a new CanceledError with the given message.
Types ¶
type AppContexter ¶
type AppContexter interface {
AppCtx() Z
}
AppContexter provides access to the application's ContextZ.
type CanceledError ¶
type CanceledError struct {
// Message provides additional context about the error.
Message string
}
CanceledError represents an error that occurred due to context cancellation.
func (*CanceledError) Error ¶
func (e *CanceledError) Error() string
Error implements the error interface for CanceledError.
type DatabaseContext ¶
type DatabaseContext interface {
context.Context
Database() *mongo.Database
GetCache(cacheName string) *sturdyc.Client[any]
}
DatabaseContext provides access to MongoDB database and caching functionality.
type Doer ¶
type Doer interface {
Doer() string
}
Doer provides the identity of the user performing an action.
type LoggerContext ¶
LoggerContext provides access to a zerolog logger instance.
func Background ¶
func Background() LoggerContext
Background returns a LoggerContext with a no-op logger for use as a background context.
type Notifier ¶
type Notifier interface {
Notify(ctx context.Context, data ...websocket.WsResponseInfo)
}
Notifier sends WebSocket notifications to connected clients.
type NotifierContext ¶
NotifierContext provides the ability to send WebSocket notifications.
type Z ¶
type Z interface {
context.Context
DatabaseContext
LoggerContext
WithContext(ctx context.Context) context.Context
}
Z is a context that consolidates all other context interfaces.