djob

package
v0.2.6 Latest Latest
Warning

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

Go to latest
Published: Dec 13, 2017 License: GPL-3.0 Imports: 32 Imported by: 1

Documentation

Index

Constants

View Source
const (
	DefaultRegion       = "MARS"
	DefaultSerfPort     = 8998
	DefaultHttpPort     = 8088
	DefaultRPCPort      = 7979
	DefaultSnapshotPath = "./snapshot"
	DefaultConfigFile   = "./conf/djob.yml"
	DefaultPidFile      = "./djob.pid"
	DefaultKeySpeace    = "djob"
	DefaultSQLPort      = 3306
	DefaultSQLHost      = "localhost"
	DefaultSQLUser      = "djob"
	DefaultDBName       = "djob"
)

default values

View Source
const (
	LOADNOTHING loadJobPolicy = 1 + iota // load nothing
	LOADOWN                              // load all the jobs belong to this server
	LOADALL                              // load all unassigned jobs
)

load job policy

View Source
const (
	QueryRunJob   = "job:run"
	QueryJobCount = "job:count"
)

string of serf query mark

View Source
const (

	// APITimeOut max api execution time
	APITimeOut = 1 * time.Second
)

Variables

View Source
var RESERVEDTAGS = [...]string{"RPCADIP", "RPCADPORT", "NODE", "REGION", "SERVER", "VERSION"}

RESERVEDTAGS store protected tag that is not allowed to be modified

Functions

This section is empty.

Types

type Agent

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

Agent djob agent struct

func New

func New(args []string, version string) *Agent

New initialization agent, args is os.agrs list

func (*Agent) AddJob

func (a *Agent) AddJob(in *pb.Job) (out *pb.Job, err error)

AddJob add job

func (*Agent) DeleteJob

func (a *Agent) DeleteJob(in *pb.Job) (out *pb.Job, err error)

delete job

func (*Agent) GetJob

func (a *Agent) GetJob(name, region string) (*pb.Job, error)

GetJob func use name and region search a job

func (*Agent) GetStatus

func (a *Agent) GetStatus(name, region string) (out *pb.JobStatus, err error)

GetStatus get job status from kv store

func (*Agent) ListExecutions

func (a *Agent) ListExecutions(in *pb.Execution, search *pb.Search) (out []*pb.Execution, count int32, err error)

ListExecutions get job executions

func (*Agent) ListJob

func (a *Agent) ListJob(in *pb.Job, search *pb.Search) (jobs []*pb.Job, count int32, err error)

ListJob find a job TODO: use concurrency instead of recursion

func (*Agent) ListNode

func (a *Agent) ListNode(node *pb.Node, search *pb.Search) (nodes []*pb.Node, count int32, err error)

ListNode get node info, support paging TODO: Need more elegant realization

func (*Agent) ListRegions

func (a *Agent) ListRegions() (regions []string, err error)

ListRegions list all available regions search in memory cache first, if no cache, set it with 120s ttl

func (*Agent) ModifyJob

func (a *Agent) ModifyJob(in *pb.Job) (out *pb.Job, err error)

ModifyJob func modify job

func (*Agent) PerformOps

func (a *Agent) PerformOps(obj interface{}, ops pb.Ops, search *pb.Search) ([]interface{}, int32, error)

PerformOps func forwarding ops to remote or perform it in local

func (*Agent) Reload

func (a *Agent) Reload(args []string)

Reload the agent

func (*Agent) RemovePid

func (a *Agent) RemovePid() error

RemovePid remove pid file

func (*Agent) Run

func (a *Agent) Run() error

Run func start a Agent process

func (*Agent) RunJob

func (a *Agent) RunJob(name, region string) (*pb.Execution, error)

RunJob implement api interface

func (*Agent) Search

func (a *Agent) Search(in interface{}, search *pb.Search) (out []interface{}, count int32, err error)

Search job or execution TODO: use concurrency instead of recursion

func (*Agent) SendBackExecution

func (a *Agent) SendBackExecution(ex *pb.Execution) (err error)

SendBackExecution handle job exec return

func (*Agent) Stop

func (a *Agent) Stop(graceful bool) int

Stop this agent

func (*Agent) WritePid

func (a *Agent) WritePid() error

WritePid create pid file

type Config

type Config struct {
	Server            bool              // start as server or just agent
	LoadJobPolicy     loadJobPolicy     // the policy for loading jobs from the database at server startup
	Region            string            // agent region
	Nodename          string            //serf node name
	Tags              map[string]string // agent tags used to filter agent
	SerfBindIP        string            // serf system bind address ip
	SerfBindPort      int
	SerfAdvertiseIP   string // serf system advertise address ip used for agent behind a firewall
	SerfAdvertisePort int
	SerfJoin          []string
	APIBindIP         string // HTTP API PORT just effect when server is true
	APIBindPort       int
	JobStore          string   // key value storage type etd/zookeeper etc.
	JobStoreServers   []string // k/v storage server list [ip:port]
	JobStoreKeyspace  string   // keyspace in the storage

	LogLevel         string // info debug error
	LogFile          string // log file path
	RPCTls           bool   // grpc enable tls or not
	CAFile           string // tls ca file used in agent
	KeyFile          string // key file used in server
	CertFile         string // cert file used in server
	RPCBindIP        string // grcp bind addr ip
	RPCBindPort      int
	RPCAdcertiseIP   string // sames to serf advertise addr
	RPCAdcertisePort int
	SerfSnapshotPath string //serf use this path to save snapshot of joined server
	DSN              string
	APITokens        map[string]string
	PidFile          string // pid file path
	// contains filtered or unexported fields
}

Config struct store agent config

func ReadConfig

func ReadConfig(version string) (*Config, error)

ReadConfig func read the configuration file

func (*Config) EncryptKey

func (c *Config) EncryptKey() ([]byte, error)

EncryptKey func base64 encode encrypt key

Jump to

Keyboard shortcuts

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