manager

package
v0.0.0-...-eaa370e Latest Latest
Warning

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

Go to latest
Published: Apr 14, 2015 License: MIT Imports: 14 Imported by: 1

Documentation

Index

Constants

View Source
const (
	MANAGER_PREFIX          = "manager:"
	CONNECTION_REFRESH_RATE = 360
	DEFAULT_MAX_WORKERS     = 20
)
View Source
const (
	MESSAGE_TYPE_CONFIG = 0
)

Variables

This section is empty.

Functions

This section is empty.

Types

type ChannelStats

type ChannelStats struct {
	Capasity int `json:"capasity"`
	Queue    int `json:"queue"`
}

ChannelStats holds statistics about a channel

type Counter

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

Counter provides methods for atomically counting things

func (*Counter) Inc

func (c *Counter) Inc()

Inc add one to the counter

func (*Counter) Set

func (c *Counter) Set(val uint64)

Set sets the counter to a given value

func (*Counter) Val

func (c *Counter) Val() uint64

Val returns the current count

type DurationCounter

type DurationCounter struct {
	sync.Mutex
	// contains filtered or unexported fields
}

DurationCounter tracks the adition of durations atomically

func (*DurationCounter) Add

func (d *DurationCounter) Add(t time.Duration)

Add add two times together atomically

func (*DurationCounter) Avg

func (d *DurationCounter) Avg() time.Duration

Avg get the averge amount of time so far

func (*DurationCounter) Reset

func (d *DurationCounter) Reset()

func (*DurationCounter) Set

func (d *DurationCounter) Set(t time.Duration)

Set set the counter to a given value

func (*DurationCounter) Val

func (d *DurationCounter) Val() time.Duration

Val returns the current total

type Manager

type Manager struct {
	// WorkerFactories a map of WorkerFactories that can create workers of a spesific type
	// WorkerFactories map[string]worker.WorkerFactory
	// // ProviderFactories a map of ProviderFactory taht can create providers fo a spesific type
	// ProviderFactories map[string]provider.ProviderFactory
	// KillChan if recieved on this channel, kill all workers
	KillChan chan struct{}
	// Stats keeps track of statistics of jobs running through the manager
	Stats *ManagerStats
	// Providers a map of provider.Provider's that can be used to request work
	Providers map[string]provider.Provider
	// contains filtered or unexported fields
}

Manager is used to manage worker processes

func NewManager

func NewManager() *Manager

NewManager create and return a referance to a manager

func (*Manager) ConfigStruct

func (m *Manager) ConfigStruct() interface{}

ConfigStruct returns the struct used to configure the manager

func (*Manager) Init

func (m *Manager) Init(i interface{}) error

Init initilize the manager

func (*Manager) Manage

func (m *Manager) Manage()

Manage create and manage workers

func (*Manager) RequestWork

func (m *Manager) RequestWork(p provider.Provider, numJobs int)

requestWork takes a map of providers, and request work from each of them

type ManagerMessage

type ManagerMessage struct {
	Type    int
	Payload interface{}
}

ManagerMessage is a message that is sent between managers to convey changes in configuration

type ManagerStats

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

ManagerStats is a struct that holds statistics about a manager

func NewManagerStats

func NewManagerStats(man *Manager) *ManagerStats

NewManagerStats initializes and returns a new instance of ManagerStats

func (*ManagerStats) AverageByProvider

func (m *ManagerStats) AverageByProvider(p provider.Provider) float64

func (*ManagerStats) AverageByType

func (m *ManagerStats) AverageByType(t string) float64

AverageByType returns the average number of job processed per second for the entire uptime of this process, for a given type

func (*ManagerStats) AverageDurationByProvider

func (m *ManagerStats) AverageDurationByProvider(p provider.Provider) time.Duration

func (*ManagerStats) AverageDurationByType

func (m *ManagerStats) AverageDurationByType(t string) time.Duration

func (*ManagerStats) IncrementJobs

func (m *ManagerStats) IncrementJobs(j job.Job)

IncrementJobs atomically add one to the total number of job

func (*ManagerStats) JobCountByProvider

func (m *ManagerStats) JobCountByProvider(p provider.Provider) uint64

func (*ManagerStats) JobCountByType

func (m *ManagerStats) JobCountByType(t string) uint64

TotalByType returns the total number of job for a given type

func (*ManagerStats) JobDurationByProvider

func (m *ManagerStats) JobDurationByProvider(p provider.Provider) time.Duration

func (*ManagerStats) JobDurationByType

func (m *ManagerStats) JobDurationByType(t string) time.Duration

func (*ManagerStats) JobsPerSecond

func (m *ManagerStats) JobsPerSecond() float64

JobsPerSecond return the job per second

func (*ManagerStats) JobsPerSecondByProvider

func (m *ManagerStats) JobsPerSecondByProvider(p provider.Provider) float64

JobsPerSecondByProvider returns the job per second for a given Provider

func (*ManagerStats) JobsPerSecondByType

func (m *ManagerStats) JobsPerSecondByType(t string) float64

JobsPerSecondByType returns the job per second of a spesific type

func (*ManagerStats) LastTotalByProvider

func (m *ManagerStats) LastTotalByProvider(p provider.Provider) uint64

func (*ManagerStats) LastTotalByType

func (m *ManagerStats) LastTotalByType(t string) uint64

func (*ManagerStats) ReportStats

func (m *ManagerStats) ReportStats(w http.ResponseWriter, r *http.Request)

ReportStats create a ManagerStatsReport for the current state of the manger

func (*ManagerStats) TotalAverage

func (m *ManagerStats) TotalAverage() float64

TotalAverage returns the average number of job processed per second for the entire uptime

func (*ManagerStats) TotalJobs

func (m *ManagerStats) TotalJobs() uint64

TotalJobs returns the total number of job processed

func (*ManagerStats) UpTime

func (m *ManagerStats) UpTime() time.Duration

UpTime returns the uptime in seconds

type ManagerStatsReport

type ManagerStatsReport struct {
	Uptime                    uint64                   `json:"uptime"`
	JobsPerSecond             float64                  `json:"job_per_second_cumulative"`
	JobsPerSecondByType       map[string]float64       `json:"job_per_second_by_type"`
	JobsPerSecondByProvider   map[string]float64       `json:"job_persecond_by_provider"`
	TotalJobs                 uint64                   `json:"total_job"`
	TotalJobsByType           map[string]uint64        `json:"total_job_by_type"`
	TotalJobsByProvider       map[string]uint64        `json:"total_job_by_provider"`
	TotalAverage              float64                  `json:"total_average"`
	TotalAverageByType        map[string]float64       `json:"total_average_by_type"`
	TotalAverageByProvider    map[string]float64       `json:"total_average_by_provider"`
	ChannelStats              map[string]ChannelStats  `json:"channel_stats"`
	AverageDurationByType     map[string]time.Duration `json:"average_duration_by_type"`
	AverageDurationByProvider map[string]time.Duration `json:"average_duration_by_provider"`
	AverageDuration           time.Duration            `json:"average_duration"`
	TotalDurationByType       map[string]time.Duration `json:"total_duration_by_type"`
	TotalDurationByProvider   map[string]time.Duration `json:"total_duration_by_provider"`
}

ManagerStatsReport holds statistical information about the mananger

Jump to

Keyboard shortcuts

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