inmem

package
v0.0.7 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 19, 2021 License: MPL-2.0 Imports: 6 Imported by: 0

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

View Source
const EventBufferSize = 16

EventBufferSize is the buffer size of the channel for each subscription.

View Source
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

type EventService struct {
	logr.Logger
	// contains filtered or unexported fields
}

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 RunLister

type RunLister interface {
	List(otf.RunListOptions) (*otf.RunList, error)
}

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.

func (*Scheduler) Start

func (s *Scheduler) Start(ctx context.Context)

Start starts the scheduler event loop

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.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL