service

package
v0.2.2 Latest Latest
Warning

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

Go to latest
Published: Mar 21, 2023 License: AGPL-3.0, Apache-2.0 Imports: 31 Imported by: 1

Documentation

Index

Constants

View Source
const (
	JobAPITypeDocker     = "docker"
	JobAPITypeKubernetes = "kubernetes"
)

Variables

This section is empty.

Functions

func JobRunnerIsValid added in v0.2.0

func JobRunnerIsValid(runner string) error

Types

type APIConfig

type APIConfig struct {
	HTTP     api.Config     `toml:"http"`
	Security SecurityConfig `toml:"security"`
}

func (APIConfig) IsValid

func (c APIConfig) IsValid() error

type Client

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

func NewClient

func NewClient(cfg ClientConfig, opts ...ClientOption) (*Client, error)

func (*Client) Close

func (c *Client) Close() error

func (*Client) CreateJob

func (c *Client) CreateJob(cfg JobConfig) (Job, error)

func (*Client) GetJob

func (c *Client) GetJob(jobID string) (Job, error)

func (*Client) GetJobLogs

func (c *Client) GetJobLogs(jobID string) ([]byte, error)

func (*Client) Login

func (c *Client) Login(clientID string, authKey string) error

func (*Client) Register

func (c *Client) Register(clientID string, authKey string) error

func (*Client) StopJob

func (c *Client) StopJob(jobID string) error

func (*Client) Unregister

func (c *Client) Unregister(clientID string) error

func (*Client) UpdateJobRunner added in v0.1.3

func (c *Client) UpdateJobRunner(runner string) error

type ClientConfig

type ClientConfig struct {
	ClientID string
	AuthKey  string
	URL      string
	// contains filtered or unexported fields
}

func (*ClientConfig) Parse

func (c *ClientConfig) Parse() error

type ClientOption

type ClientOption func(c *Client) error

func WithDialFunc

func WithDialFunc(dialFn DialContextFn) ClientOption

WithDialFunc lets the caller set an optional dialing function to setup the HTTP/WebSocket connections used by the client.

type Config

type Config struct {
	API    APIConfig
	Store  StoreConfig
	Jobs   JobsConfig
	Logger logger.Config
}

func (Config) IsValid

func (c Config) IsValid() error

func (*Config) SetDefaults

func (c *Config) SetDefaults()

type DialContextFn

type DialContextFn func(ctx context.Context, network, addr string) (net.Conn, error)

type Job

type Job struct {
	JobConfig
	ID         string         `json:"id"`
	StartAt    int64          `json:"start_at"`
	StopAt     int64          `json:"stop_at,omitempty"`
	OutputData map[string]any `json:"output_data,omitempty"`
}

type JobAPIType

type JobAPIType string

type JobConfig

type JobConfig struct {
	Type           JobType        `json:"type"`
	MaxDurationSec int64          `json:"max_duration_sec"`
	Runner         string         `json:"runner"`
	InputData      map[string]any `json:"input_data,omitempty"`
}

func (JobConfig) IsValid

func (c JobConfig) IsValid() error

type JobService

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

func NewJobService

func NewJobService(cfg JobsConfig, log *mlog.Logger) (*JobService, error)

func (*JobService) CreateRecordingJobDocker

func (s *JobService) CreateRecordingJobDocker(cfg JobConfig, onStopCb stopCb) (Job, error)

func (*JobService) RecordingJobLogsDocker

func (s *JobService) RecordingJobLogsDocker(jobID string) ([]byte, error)

func (*JobService) RemoveRecordingJobDocker added in v0.1.2

func (s *JobService) RemoveRecordingJobDocker(jobID string) error

func (*JobService) StopRecordingJobDocker

func (s *JobService) StopRecordingJobDocker(jobID string) error

func (*JobService) UpdateJobRunnerDocker added in v0.1.3

func (s *JobService) UpdateJobRunnerDocker(runner string) error

type JobType

type JobType string
const (
	JobTypeRecording JobType = "recording"
)

type JobsConfig

type JobsConfig struct {
	APIType           JobAPIType `toml:"api_type"`
	MaxConcurrentJobs int        `toml:"max_concurrent_jobs"`
}

func (JobsConfig) IsValid

func (c JobsConfig) IsValid() error

type SecurityConfig

type SecurityConfig struct {
	// Whether or not to enable admin API access.
	EnableAdmin bool `toml:"enable_admin"`
	// The secret key used to authenticate admin requests.
	AdminSecretKey string `toml:"admin_secret_key"`
	// Whether or not to allow clients to self-register.
	AllowSelfRegistration bool                    `toml:"allow_self_registration"`
	SessionCache          auth.SessionCacheConfig `toml:"session_cache"`
}

func (SecurityConfig) IsValid

func (c SecurityConfig) IsValid() error

type Service

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

func New

func New(cfg Config) (*Service, error)

func (*Service) DeleteJob

func (s *Service) DeleteJob(jobID string) error

func (*Service) GetJob

func (s *Service) GetJob(jobID string) (Job, error)

func (*Service) SaveJob

func (s *Service) SaveJob(job Job) error

func (*Service) Start

func (s *Service) Start() error

func (*Service) Stop

func (s *Service) Stop() error

type StoreConfig

type StoreConfig struct {
	DataSource string `toml:"data_source"`
}

func (StoreConfig) IsValid

func (c StoreConfig) IsValid() error

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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