master

package
v0.0.0-...-37de26c Latest Latest
Warning

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

Go to latest
Published: Jul 19, 2023 License: Apache-2.0 Imports: 29 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrAppNotRunning = errors.New("application is not running")
	ErrAppIsFinished = errors.New("application is finished already")
	ErrAppIsCanceled = errors.New("application is canceled")
	ErrCantDeleteApp = errors.New("cannot delete a %s application")
)

Error

Functions

This section is empty.

Types

type Master

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

func NewMaster

func NewMaster(opts *Options, logger logger.Logger) (m *Master, err error)

NewMaster will setup a new master struct given options and logger. Could return an error if options can not be validated.

func (*Master) CancelApplication

func (m *Master) CancelApplication(ctx context.Context, appID int) (*ent.Application, error)

CancelApplication terminates an application if the app is running, send cancel signal if the app is finished/error, return ErrAppIsFinished error if the app is canceled, return with current app status else update app status with cancel

func (*Master) CleanupRunningApps

func (m *Master) CleanupRunningApps() (err error)

CleanupRunningApps update last running app status from running -> error It should be called when the master is booted

func (*Master) Counter

func (m *Master) Counter(ctx context.Context, req *pb.CounterReq) (*pb.CounterRes, error)

func (*Master) DbClient

func (m *Master) DbClient() *ent.Client

DbClient returns the db client

func (*Master) DeleteApplication

func (m *Master) DeleteApplication(ctx context.Context, appID int) error

DeleteApplication a pending/finished/canceled/error application

func (*Master) FindCreateGraph

func (m *Master) FindCreateGraph(ctx context.Context, req *pb.FCGraphReq) (res *pb.FCGraphRes, err error)

func (*Master) FindCreateGroup

func (m *Master) FindCreateGroup(ctx context.Context, req *pb.FCGroupReq) (res *pb.FCGroupRes, err error)

FindCreateGroup find or create new group return the existing/new group ent, is created, and error

func (*Master) FindCreateMetric

func (m *Master) FindCreateMetric(ctx context.Context, req *pb.FCMetricReq) (res *pb.FCMetricRes, err error)

func (*Master) Gauge

func (m *Master) Gauge(ctx context.Context, req *pb.GaugeReq) (*pb.GaugeRes, error)

func (*Master) GetHostname

func (m *Master) GetHostname() string

GetHostname returns the hostname

func (*Master) GetTagByApplication

func (m *Master) GetTagByApplication(ctx context.Context, app *ent.Application, tagName string) (*ent.Tag, error)

GetTagByApplication get a tag for an application

func (*Master) GetTagByID

func (m *Master) GetTagByID(ctx context.Context, tagID int) (*ent.Tag, error)

GetTagByID get a tag for an application

func (*Master) Histogram

func (m *Master) Histogram(ctx context.Context, req *pb.HistogramReq) (*pb.HistogramRes, error)

func (*Master) Logpaths

func (m *Master) Logpaths(appID int) (string, string, string)

Logpaths for an application ID returns folder path, system log filepath, and user log filepath

func (*Master) NewApplication

func (m *Master) NewApplication(ctx context.Context, name, scenario, gomod, gosum string) (
	*ent.Application, error,
)

NewApplication create a new application with a name and a scenario return the application id and error

func (*Master) PingDb

func (m *Master) PingDb() error

PingDb health check the using database

func (*Master) RemoveApplicationTag

func (m *Master) RemoveApplicationTag(ctx context.Context, tag *ent.Tag) error

RemoveApplicationTag remove tag from an application

func (*Master) SetApplicationTag

func (m *Master) SetApplicationTag(ctx context.Context, appID int, tag string) (*ent.Tag, error)

SetApplicationTag create and new tag and assign it for an application

func (*Master) SetIsScheduled

func (m *Master) SetIsScheduled(is bool) *Master

SetIsScheduled update isScheduled property

func (*Master) Start

func (m *Master) Start() (err error)

func (*Master) Varz

func (m *Master) Varz() (*Varz, error)

Varz returns a Varz struct containing the server information.

func (*Master) WebPort

func (m *Master) WebPort() int

WebPort returns the master HTTP web port

type Options

type Options struct {
	Port    int
	Addr    string
	Program string
	HomeDir string
}

type Varz

type Varz struct {
	ID        string    `json:"server_id"`
	Version   string    `json:"version"`
	GitCommit string    `json:"git_commit,omitempty"`
	GoVersion string    `json:"go"`
	Start     time.Time `json:"start"`
	Now       time.Time `json:"now"`
	Uptime    string    `json:"uptime"`
	Mem       uint64    `json:"mem"`
	Cores     int       `json:"cores"`
	MaxProcs  int       `json:"gomaxprocs"`
	CPU       float64   `json:"cpu"`
}

Varz outputs master information at /varz

Jump to

Keyboard shortcuts

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