infoworker

package
v1.0.1-alpha Latest Latest
Warning

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

Go to latest
Published: Aug 7, 2019 License: Apache-2.0 Imports: 11 Imported by: 0

README

Info Worker

This worker is used for health check and workers monitoring via API

  • Allows to specify route prefix; mount pprof
  • Api

##How to use:

  1. Add following structure into config file:

    info_worker:
        host: localhost
        port: 2443
        profiler: true
        prefix: "/test"
    

    Where profiler property is responsible for mounting net/http/pprof from chi middleware.Profiler()

  2. Initialize worker:

    worker := infoworker.GetInfoWorker(wApi, ctx, wInfo)
    

    Where:

    • wApi --> Conf structure with worker configuration
    • ctx --> background context with pointer to worker chief
    • wInfo --> Info structure with info about current service

    This structures belong to infoworker packages

  3. Add worker into worker chief and config struct

    WorkerChief.AddWorker("info-server", worker)
    

###Warning! Run this worker only in dev mode

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Conf

type Conf struct {
	Host     string `json:"host" yaml:"host"`
	Port     int    `json:"port" yaml:"port"`
	Profiler bool   `json:"profiler" yaml:"profiler"`
	Prefix   string `json:"prefix" yaml:"prefix"`
}

structure with configuration for worker

type Info

type Info struct {
	App     string `json:"app"`
	Version string `json:"version"`
	Tag     string `json:"tag"`
	Build   string `json:"build"`
}

DEPRECATED structure with info about service

type InfoWorker

type InfoWorker struct {
	api.Server

	Info   Info
	Config Conf
	// contains filtered or unexported fields
}

func GetInfoWorker

func GetInfoWorker(cfg Conf, ctx context.Context, info Info) *InfoWorker

GetInfoWorker returns initialized info worker struct. !Context must contain pointer to worker chief!

func (*InfoWorker) GetInfoRouter

func (iw *InfoWorker) GetInfoRouter(logger *logrus.Entry, cfg api.Config) http.Handler

GetInfoRouter returns workers api

func (*InfoWorker) Version

func (iw *InfoWorker) Version(w http.ResponseWriter, r *http.Request)

Version is a handler which responses with Info structure

func (*InfoWorker) Workers

func (iw *InfoWorker) Workers(w http.ResponseWriter, r *http.Request)

Workers is a handler which responses with JSON with all workers in parent chief

Jump to

Keyboard shortcuts

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