Documentation
¶
Overview ¶
Package inmem implements a layer of services in memory using purely Go constructs. In theory, they can be swapped out for services implemented using other tech, e.g. databases, redis, etc.
Index ¶
Constants ¶
const EventBufferSize = 16
EventBufferSize is the buffer size of the channel for each subscription.
const ( // SchedulerSubscriptionID is the ID the scheduler uses to identify itself // when subscribing to the events service SchedulerSubscriptionID = "scheduler" )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type EventService ¶
func NewEventService ¶
func NewEventService(logger logr.Logger) *EventService
NewEventService returns a new instance of EventService.
func (*EventService) Publish ¶
func (e *EventService) Publish(event otf.Event)
func (*EventService) Subscribe ¶
func (e *EventService) Subscribe(id string) otf.Subscription
func (*EventService) Unsubscribe ¶
func (e *EventService) Unsubscribe(sub *Subscription)
Unsubscribe disconnects sub from the service.
type Scheduler ¶
type Scheduler struct {
// Queues is a mapping of workspace ID to workspace queue of runs
Queues map[string]otf.Queue
// RunService retrieves and updates runs
otf.RunService
// EventService permits scheduler to subscribe to a stream of events
otf.EventService
// Logger for logging various events
logr.Logger
}
Scheduler manages workspaces' run queues in memory. It subscribes to events and updates the queues accordingly.
func NewScheduler ¶
func NewScheduler(ws otf.WorkspaceService, rs otf.RunService, es otf.EventService, logger logr.Logger) (*Scheduler, error)
NewScheduler constructs scheduler queues and populates them with existing runs.
type Subscription ¶
type Subscription struct {
// contains filtered or unexported fields
}
Subscription represents a stream of events.
func (*Subscription) C ¶
func (s *Subscription) C() <-chan otf.Event
C returns a receive-only channel of user-related events.
func (*Subscription) Close ¶
func (s *Subscription) Close() error
Close disconnects the subscription from the service it was created from.