executor

package
v0.0.2 Latest Latest
Warning

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

Go to latest
Published: Jul 22, 2021 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	NodePath                     string
	DefaultMaximumCommandRuntime int
}

Config defines configuration for this provider

type Dependencies

type Dependencies struct {
	Logger        zerolog.Logger
	CommandRuns   providers.CommandRunStorer
	CommandStorer providers.CommandStorer
	Clock         providers.Clock
}

Dependencies defines dependencies for this provider

type InMemoryExecuter

type InMemoryExecuter struct {
	Config
	Dependencies
	// contains filtered or unexported fields
}

InMemoryExecuter defines an Executor which runs commands alongside Krok. It saves runs in a map and constantly updates it. Cancelling will go over all processes belonging to that run and kill them.

func NewInMemoryExecuter

func NewInMemoryExecuter(cfg Config, deps Dependencies) *InMemoryExecuter

NewInMemoryExecuter creates a new InMemoryExecuter which will hold all runs in its memory. In case of a crash, human intervention will be required. TODO: Later, save runs in db with the process id to cancel so Krok can pick up runs again.

func (*InMemoryExecuter) CancelRun

func (ime *InMemoryExecuter) CancelRun(ctx context.Context, id int) error

CancelRun will cancel a run and mark all commands as cancelled then remove the entry from the run map. If the kill was unsuccessful, the user can try running it again.

func (*InMemoryExecuter) CreateRun

func (ime *InMemoryExecuter) CreateRun(ctx context.Context, event *models.Event, commands []*models.Command) error

CreateRun creates a run for an event.

Jump to

Keyboard shortcuts

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