session

package
v0.2.1 Latest Latest
Warning

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

Go to latest
Published: Jan 21, 2024 License: BSD-3-Clause Imports: 27 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrAlreadyExists = errors.New("job already exists")
View Source
var ErrNotFound = errors.New("job not found")

Functions

func Lockfile

func Lockfile() (lockfile.Lockfile, error)

func Running

func Running() bool

func TryAcquire

func TryAcquire() bool

Types

type Collection

type Collection[K any, V any] struct {
	DB     *badger.DB
	Prefix []byte
}

Collections.

func (*Collection[K, V]) Clear

func (c *Collection[K, V]) Clear()

func (*Collection[K, V]) Count

func (c *Collection[K, V]) Count() (count int)

func (*Collection[K, V]) Delete

func (c *Collection[K, V]) Delete(key K)

func (*Collection[K, V]) Get

func (c *Collection[K, V]) Get(key K) (value V, ok bool)

func (*Collection[K, V]) Has

func (c *Collection[K, V]) Has(key K) bool

func (*Collection[K, V]) Insert

func (c *Collection[K, V]) Insert(key K, value V) (inserted bool)

func (*Collection[K, V]) MarshalKey

func (c *Collection[K, V]) MarshalKey(k K) []byte

func (*Collection[K, V]) MarshalValue

func (c *Collection[K, V]) MarshalValue(v V) []byte

func (*Collection[K, V]) Open

func (c *Collection[K, V]) Open(db *badger.DB, prefix string)

func (*Collection[K, V]) Range

func (c *Collection[K, V]) Range(f func(key K, item V) bool)

func (*Collection[K, V]) Replace

func (c *Collection[K, V]) Replace(key K, value V) (prev V, existed bool)

func (*Collection[K, V]) UnmarshalKey

func (c *Collection[K, V]) UnmarshalKey(k *K, b []byte) error

func (*Collection[K, V]) UnmarshalValue

func (c *Collection[K, V]) UnmarshalValue(v *V, b []byte) error

func (*Collection[K, V]) Upsert

func (c *Collection[K, V]) Upsert(key K, cb func(value *V) V)

type DaemonService

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

func (*DaemonService) Ping

func (s *DaemonService) Ping(x, y *int) error

func (*DaemonService) Shutdown

func (s *DaemonService) Shutdown(_ *any, _ *any) error

type EventService

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

func (*EventService) Signal

func (s *EventService) Signal(name *string, _ *any) error

type JobService

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

func (*JobService) Delete

func (s *JobService) Delete(match *string, list *[]string) error

func (*JobService) Kill

func (s *JobService) Kill(match *string, list *[]string) error

func (*JobService) Launch

func (s *JobService) Launch(recipe job.Manifest, result *RpcJobInfo) error

func (*JobService) List

func (s *JobService) List(match *string, result *RpcSessionJobs) error

func (*JobService) Restart

func (s *JobService) Restart(match *string, list *[]string) error

func (*JobService) Start

func (s *JobService) Start(match *string, list *[]string) error

func (*JobService) Stop

func (s *JobService) Stop(match *string, list *[]string) error

func (*JobService) Update

func (s *JobService) Update(recipe job.Manifest, result *RpcJobInfo) error

type RpcJobInfo

type RpcJobInfo struct {
	ID   string      `json:"id"`
	Main RpcTaskInfo `json:"main"`
}

type RpcLogMessage

type RpcLogMessage struct {
	Kind string `json:"kind"`
	Line string `json:"line"`
}

type RpcSessionJobs

type RpcSessionJobs struct {
	Jobs []RpcJobInfo `json:"jobs"`
}

type RpcStatus

type RpcStatus struct {
	Icon  string `json:"icon"`
	Code  string `json:"code"`
	Error string `json:"error,omitempty"`
}

type RpcTaskInfo

type RpcTaskInfo struct {
	Namespace string        `json:"namespace"`
	Status    RpcStatus     `json:"status"`
	Report    task.Report   `json:"report,omitempty"`
	Children  []RpcTaskInfo `json:"children,omitempty"`
}

type RpcWhiteboardKey

type RpcWhiteboardKey struct {
	Job string `json:"job,omitempty"`
	Key string `json:"key"`
}

type RpcWhiteboardKv

type RpcWhiteboardKv struct {
	RpcWhiteboardKey
	Value json.RawMessage `json:"value,omitempty"`
}

type Session

type Session struct {
	Database  *badger.DB
	RpcServer *surpc.Server

	Jobs          sync.Map
	JobCollection Collection[string, job.Manifest]
	// contains filtered or unexported fields
}

func Open

func Open() (s *Session)

func (*Session) Close

func (s *Session) Close(err error)

func (*Session) DeleteJob

func (s *Session) DeleteJob(id string) error

func (*Session) ForEachJob

func (s *Session) ForEachJob(match string, cb func(j *job.Job) error) (e error)

func (*Session) ForEachJobRgx

func (s *Session) ForEachJobRgx(pattern *regexp.Regexp, cb func(j *job.Job) error) (e error)

func (*Session) InsertJob

func (s *Session) InsertJob(j *job.Job) error

func (*Session) LogsHandler

func (s *Session) LogsHandler(w http.ResponseWriter, r *http.Request)

func (*Session) StopAll

func (s *Session) StopAll(timeout time.Duration)

func (*Session) UpdateJob

func (s *Session) UpdateJob(j *job.Job)

func (*Session) Wait

func (s *Session) Wait() error

type WhiteboardService

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

func (*WhiteboardService) Get

func (*WhiteboardService) Put

func (s *WhiteboardService) Put(key *RpcWhiteboardKv, count *int) error

Jump to

Keyboard shortcuts

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