runtime

package
v0.0.0-...-9fce2f1 Latest Latest
Warning

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

Go to latest
Published: May 2, 2022 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrUnavailableRetriever = errors.New("unavailable source retriever")

Functions

func Delete

func Delete(id string, opts ...Option) error

func NewHandler

func NewHandler() pb.RuntimeServer

Types

type Instance

type Instance interface {
	Id() string
	Stop() error
	Stat() *Stat
}

func Create

func Create(source string, opts ...Option) (Instance, error)

func List

func List(opts ...Option) ([]Instance, error)

type Message

type Message struct {
	Type   MessageType
	Source *Source
	Time   time.Time
}

func (Message) Timestamp

func (m Message) Timestamp() int64

func (Message) Topic

func (m Message) Topic() string

type MessageType

type MessageType int
const (
	EventCreate MessageType = iota
	EventDelete
)

type Option

type Option func(*Options)

func Args

func Args(args []string) Option

func Broker

func Broker(b broker.Broker) Option

func Context

func Context(c context.Context) Option

func Deps

func Deps(deps []string) Option

func Dir

func Dir(dir string) Option

func Envs

func Envs(env []string) Option

func Namespace

func Namespace(ns string) Option

func Writer

func Writer(w io.Writer) Option

type Options

type Options struct {
	Context   context.Context
	Namespace string
	Dir       string

	Writer io.Writer
	Reader io.Reader

	// for method Create
	Args []string
	Env  []string
	Deps []string // e.g. numpy=1.2.10

	// for method Watch
	Broker broker.Broker
}

type Runtime

type Runtime interface {
	// Create retrieves a source including the script and its
	// model if necessary in a specific virtual environment.
	Create(string, ...Option) (Instance, error)
	// Delete deletes a service by its id, or do nothing if the
	// service is not found.
	Delete(string, ...Option) error
	// List lists all services
	List(...Option) ([]Instance, error)
	// Watch watches events from runtime. e.g. instance creation
	Watch() (Watcher, error)
	// Close blocks until all the service and sessions are finished,
	// then closes the runtime itself.
	Close() error
}
var DefaultRuntime Runtime

type Source

type Source struct {
	Name    string
	Version string
	Path    string
	Model   string
	Runner  string // e.g. base@conda
	Address string
	Scheme  map[string]string
}

func Retrieve

func Retrieve(source, namespace, root string) (*Source, error)

type Stat

type Stat struct {
	State  State
	Source *Source
	Ctime  time.Time
	Err    error
}

type State

type State int
const (
	Pendding State = iota
	Active
	Exited
)

type Watcher

type Watcher interface {
	Next() (*Message, error)
	Close() error
}

func Watch

func Watch() (Watcher, error)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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