setup

package
v0.0.2-alpha Latest Latest
Warning

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

Go to latest
Published: Jun 19, 2025 License: Apache-2.0 Imports: 17 Imported by: 0

README

Scoot Setup

This package Cloud Scoot Setup, which is a mechanism for running Scoot with local components, or initializing a connection to remote ones, depending on configuration.

  • worker - interface for scheduler to start tasks on a worker & manage responses re: status of in progress tasks.
    • workers - implementations of the worker interface (polling worker, etc), that invoke a runner

Documentation

Overview

Package setup provides Cloud Scoot Setup, which is a mechanism for running Scoot with local components, or initializing a connection to remote ones, depending on configuration.

Index

Constants

View Source
const DefaultApiServerCount int = 3
View Source
const DefaultApiServerLogLevel log.Level = log.InfoLevel
View Source
const DefaultWorkerCount int = 5
View Source
const DefaultWorkerLogLevel log.Level = log.InfoLevel

Variables

This section is empty.

Functions

func GoPath

func GoPath() (string, error)

func Main

func Main(cmds *Cmds, strategies *Strategies, args []string) error

Main is the entry point for Cloud Scoot setup. cmds is running commands strategies.sched maps strings to SchedulerStrategy strategies.schedStrategy is the name of the strategy to use same applies to bundlestore strategy. args is the remaining arguments. These can be used to run a command

func RepoRoot

func RepoRoot(goPath string) string

func WaitForPort

func WaitForPort(port int) error

WaitForPort waits 10 seconds for a process to listen to the port, and returns an error if the port remains open

func WaitForPortTimeout

func WaitForPortTimeout(port int, timeout time.Duration) error

WaitForPortTimeout waits timeout for a process to listen to the port, and returns an error if the port remains open

Types

type ApiConfig

type ApiConfig struct {
	Count    int
	LogLevel log.Level
}

We set the number of apiserver instances to start. A default value will be assigned if unitialized. We also set a logLevel, which determines the minimum level to display in apiserver logs.

type ApiStrategy

type ApiStrategy interface {
	// Startup starts up an ApiServer, returing the address of the server or an error
	Startup() ([]string, error)
}

ApiStrategy will startup with a bundlestore (or setup a connection to one)

type Builder

type Builder interface {
	// Scheduler returns the path to the Scheduler binary (or an error if it can't be built)
	Scheduler() (string, error)
	// Worker returns the path to the Worker binary (or an error if it can't be built)
	Worker() (string, error)
	// ApiServer returns the path to the Worker binary (or an error if it can't be built)
	ApiServer() (string, error)
}

Builder is able to create Scoot binaries

type Cmds

type Cmds struct {
	// contains filtered or unexported fields
}

Cmds runs commands for Cloud Scoot setup. Over os/exec, it offers: *) (best-effort) clean-up (via Kill()) *) logging when a process is started *) output redirection (TODO) *) Utility functions for Fatal logging that also Kill *) Kills all commands when any long-lived command finishes (to allow prompt debugging) Setup code that might start long-running commands should use Command instead of exec.Command, and StartCmd/StartRun instead of cmd.Start/cmd.Run Run and Start are convenience methods to make it easier to run stuff The main entry points Run() or Start() are convenience

func NewCmds

func NewCmds() *Cmds

Create a new Cmds

func NewSignalHandlingCmds

func NewSignalHandlingCmds() *Cmds

Create a new Cmds that has a signal handler installed

func (*Cmds) Command

func (c *Cmds) Command(path string, arg ...string) *exec.Cmd

Commands creates a Command that is watched (and with appropriate redirection)

func (*Cmds) Kill

func (c *Cmds) Kill()

Kill kills all running commands NB: we can't guarantee this is called before exiting. If we really want to be correct, we have to start another process that will do the babysitting.

func (*Cmds) Run

func (c *Cmds) Run(path string, arg ...string) error

Run is a convenience method that calls Command and then RunCmd

func (*Cmds) RunCmd

func (c *Cmds) RunCmd(cmd *exec.Cmd) error

RunCmd runs a Cmd that was created by Command

func (*Cmds) Start

func (c *Cmds) Start(path string, arg ...string) error

Start is a convenience method that calls Command and then StartCmd

func (*Cmds) StartCmd

func (c *Cmds) StartCmd(cmd *exec.Cmd) error

StartCmd starts a Cmd that was created by Command and expects it to run forever If cmd stops, c will call c.Kill() (to allow prompt debugging)

type GoBuilder

type GoBuilder struct {
	// contains filtered or unexported fields
}

GoBuilder uses the go command-line tools to build Scoot

func NewGoBuilder

func NewGoBuilder(cmds *Cmds) *GoBuilder

NewGoBuilder creates a GoBuilder

func (*GoBuilder) ApiServer

func (b *GoBuilder) ApiServer() (string, error)

func (*GoBuilder) Scheduler

func (b *GoBuilder) Scheduler() (string, error)

func (*GoBuilder) Worker

func (b *GoBuilder) Worker() (string, error)

type InMemoryWorkersStrategy

type InMemoryWorkersStrategy struct {
	// contains filtered or unexported fields
}

InMemoryWorkersStrategy will use in-memory workers (to test the Scheduler logic)

func NewInMemoryWorkers

func NewInMemoryWorkers(workersCfg *WorkerConfig) *InMemoryWorkersStrategy

NewInMemoryWorkers creates a new InMemoryWorkersStartup

func (*InMemoryWorkersStrategy) StartupWorkers

func (s *InMemoryWorkersStrategy) StartupWorkers() (string, error)

type LocalApiStrategy

type LocalApiStrategy struct {
	// contains filtered or unexported fields
}

LocalApiStrategy starts up a local apiserver

func NewLocal

func NewLocal(apiCfg *ApiConfig, builder Builder, cmds *Cmds) *LocalApiStrategy

Create an ApiServer Strategy with a local apiserver.

func NewLocalApiStrategy

func NewLocalApiStrategy(apiCfg *ApiConfig, builder Builder, cmds *Cmds) *LocalApiStrategy

Create a new Local ApiServer that will serve the bundlestore api, using builder and cmds to start

func (*LocalApiStrategy) Startup

func (s *LocalApiStrategy) Startup() ([]string, error)

type LocalSchedStrategy

type LocalSchedStrategy struct {
	// contains filtered or unexported fields
}

LocalSchedStrategy starts up a local scheduler

func NewLocalLocal

func NewLocalLocal(workersCfg *WorkerConfig, builder Builder, cmds *Cmds) *LocalSchedStrategy

Create a SchedulerStrategy with a local scheduler and local workers

func NewLocalMemory

func NewLocalMemory(workersCfg *WorkerConfig, builder Builder, cmds *Cmds) *LocalSchedStrategy

Create a SchedulerStrategy with a local scheduler and in-memory workers

func NewLocalSchedStrategy

func NewLocalSchedStrategy(workersCfg *WorkerConfig, workers WorkersStrategy, builder Builder, cmds *Cmds) *LocalSchedStrategy

Create a new Local Scheduler that will talk to workers, using builder and cmds to start

func (*LocalSchedStrategy) Startup

func (s *LocalSchedStrategy) Startup() (string, error)

type LocalWorkersStrategy

type LocalWorkersStrategy struct {
	// contains filtered or unexported fields
}

LocalWorkersStrategy will startup workers running locally

func NewLocalWorkers

func NewLocalWorkers(workersCfg *WorkerConfig, builder Builder, cmds *Cmds) *LocalWorkersStrategy

NewLocalWorkers creates a new LocalWorkersStartup

func (*LocalWorkersStrategy) StartupWorkers

func (s *LocalWorkersStrategy) StartupWorkers() (string, error)

type SchedulerStrategy

type SchedulerStrategy interface {

	// Startup starts up a Scheduler, returning the address of the server or an error
	Startup() (string, error)
}

SchedulerStrategy will startup a Scheduler (or setup a connection to one)

type Strategies

type Strategies struct {
	Sched         map[string]SchedulerStrategy
	SchedStrategy string
	Api           map[string]ApiStrategy
	ApiStrategy   string
}

type WorkerConfig

type WorkerConfig struct {
	Count    int
	RepoDir  string
	LogLevel log.Level
}

In addition to count, we'll optionally want repoDir to initialize workers' gitdb. Whatever is unset will be given a default value. We also set a logLevel, which determines the minimum level to display in scheduler/worker logs.

type WorkersStrategy

type WorkersStrategy interface {
	// StartupWorkers should startup necessary workers, and returns the config to pass to Scheduler, or an error
	StartupWorkers() (string, error)
}

WorkersStrategy is a strategy to start workers and returns the config to pass to a scheduler to talk to them

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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