stdserv

package
v0.0.0-...-21c7af1 Latest Latest
Warning

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

Go to latest
Published: Oct 24, 2020 License: MIT Imports: 12 Imported by: 1

Documentation

Index

Constants

View Source
const (
	DEFAULT_APP_CONFIG = "/data/app.json"
	SERVICE_STATE_FILE = "/data/__service_state.json"
)

Variables

View Source
var DEFAULT_WORKER_START_CONF = obrero.WorkerStartConf{
	PoolSize:            2,
	Duration:            20 * time.Second,
	RetryDuration:       20 * time.Second,
	NAGetClientMaxRetry: 3,
}

Functions

func StartStdWorker

func StartStdWorker(appConfig interface{}, appState interface{}, getBoxFuncMap GetBoxFuncMap, stdWorkerConfig StdWorkerConfig) napool.NAPools

appConfig: pointer of appConfig appState: pointer of appState

Types

type GetBoxFuncMap

type GetBoxFuncMap = func(*napool.NAPools, *WorkerState, *gopcp_stream.StreamServer) map[string]*gopcp.BoxFunc

(pool, config pointer, stream)

type State

type State struct {
	StateId string      `json: "stateId"`
	Data    interface{} `json:"data"`
}

type StdWorkerConfig

type StdWorkerConfig struct {
	// TODO read ServiceName from env
	ServiceName       string
	AppConfigFilePath *string
	WorkerStartConf   *obrero.WorkerStartConf
	BeforeStartWorker func()
	AfterStartWorker  func(*napool.NAPools)
	Nonblocking       bool
}

type WorkerState

type WorkerState struct {
	StateFilePath string
	State         State
	// contains filtered or unexported fields
}

func GetWorkerState

func GetWorkerState(stateFilePath string) (*WorkerState, error)

read state from state file

func (*WorkerState) UpdateState

func (ws *WorkerState) UpdateState() error

flush current state to file TODO lock

Jump to

Keyboard shortcuts

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