Documentation ¶
Index ¶
- type Config
- type LogEvent
- type Stats
- type WorkClient
- func (c *WorkClient) Close()
- func (client *WorkClient) Configure(config Config, executeWorkFn, closeExecuteWorkFn func())
- func (c *WorkClient) Log(level, msg string, err error)
- func (c *WorkClient) LogErr(err error)
- func (c *WorkClient) LogF(level, format string, vals ...interface{})
- func (c *WorkClient) LogInfo(msg string)
- func (c *WorkClient) LogInfoF(format string, vals ...interface{})
- func (c *WorkClient) NewGauge(metric string) metrics.Gauge
- func (c *WorkClient) NewTimer(metric string) metrics.Timer
- func (c *WorkClient) Run()
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Config ¶
type Config struct { // Standard configuration values StatsdAddr string `toml:"statsd_addr"` StatsdInterval int `toml:"statsd_interval"` StatsdPrefix string `toml:"statsd_prefix"` StdErrLogFile string `toml:"stderr_logfile"` GraphiteAddr string `toml:"graphite_addr"` GraphitePrefix string `toml:"graphite_prefix"` EtcdAddr string `toml:"etcd_addr"` EtcdCaCert string `toml:"etcd_cacert"` EtcdTlsKey string `toml:"etcd_tlskey"` EtcdTlsCert string `toml:"etcd_tlscert"` EtcdPrefixKey string `toml:"etcd_prefix_key"` EtcdHeartbeatTtl int `toml:"etcd_heartbeat_ttl"` ServiceName string `toml:"service_name"` Hostname string `toml:"hostname"` // web configuration WebAddr string `toml:"web_addr" default:"0.0.0.0:5000"` ReadTimeout time.Duration `toml:"web_read_timeout" default:"10s"` WriteTimeout time.Duration `toml:"web_write_timeout" default:"10s"` MaxHeaderBytes int `toml:"web_max_header_bytes" default:"65536"` }
Config represents a simple work service configuration
type LogEvent ¶
type LogEvent struct { Level string // level represents a string used for the event level or type Message string // message associated with the event occurring Err error // error potentially associated with this event Buf []byte // buffer of a potential runtime stack }
LogEvent represents a simple construct for when 'things' occur in the application on certain levels
type Stats ¶
type Stats struct { Time int64 `json:"time"` // runtime GoVersion string `json:"go_version"` GoOs string `json:"go_os"` GoArch string `json:"go_arch"` CpuNum int `json:"cpu_num"` GoroutineNum int `json:"goroutine_num"` Gomaxprocs int `json:"gomaxprocs"` CgoCallNum int64 `json:"cgo_call_num"` ProcessId int `json:"process_id"` Hostname string `json:"hostname"` // memory MemoryAlloc uint64 `json:"memory_alloc"` MemoryTotalAlloc uint64 `json:"memory_total_alloc"` MemorySys uint64 `json:"memory_sys"` MemoryLookups uint64 `json:"memory_lookups"` MemoryMallocs uint64 `json:"memory_mallocs"` MemoryFrees uint64 `json:"memory_frees"` // stack StackInUse uint64 `json:"memory_stack"` // heap HeapAlloc uint64 `json:"heap_alloc"` HeapSys uint64 `json:"heap_sys"` HeapIdle uint64 `json:"heap_idle"` HeapInuse uint64 `json:"heap_inuse"` HeapReleased uint64 `json:"heap_released"` HeapObjects uint64 `json:"heap_objects"` // garbage collection GcNext uint64 `json:"gc_next"` GcLast uint64 `json:"gc_last"` GcNum uint32 `json:"gc_num"` GcPerSecond float64 `json:"gc_per_second"` GcPausePerSecond float64 `json:"gc_pause_per_second"` GcPause []float64 `json:"gc_pause"` }
func GetRuntimeStats ¶
type WorkClient ¶
type WorkClient struct { Config Config Header string Version string // contains filtered or unexported fields }
func (*WorkClient) Configure ¶
func (client *WorkClient) Configure(config Config, executeWorkFn, closeExecuteWorkFn func())
Configure the client according to the given configuration and initialize state
func (*WorkClient) Log ¶
func (c *WorkClient) Log(level, msg string, err error)
Log will log the msg and level
func (*WorkClient) LogErr ¶
func (c *WorkClient) LogErr(err error)
LogErr will log a simple error level event
func (*WorkClient) LogF ¶
func (c *WorkClient) LogF(level, format string, vals ...interface{})
LogF will log the given level and formatted values
func (*WorkClient) LogInfo ¶
func (c *WorkClient) LogInfo(msg string)
LogInfo will log the message as an info level
func (*WorkClient) LogInfoF ¶
func (c *WorkClient) LogInfoF(format string, vals ...interface{})
func (*WorkClient) NewGauge ¶
func (c *WorkClient) NewGauge(metric string) metrics.Gauge
NewGauge will create a gauge formatted with the service name and metric and register it with go-metrics
func (*WorkClient) NewTimer ¶
func (c *WorkClient) NewTimer(metric string) metrics.Timer
NewTimer will create a timer formatted with the service name and metric and register it with go-metrics
func (*WorkClient) Run ¶
func (c *WorkClient) Run()
Runs all goroutines for signals, closing, connect routines..etc