bolt

package
v1.1.3 Latest Latest
Warning

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

Go to latest
Published: Mar 5, 2019 License: MPL-2.0 Imports: 36 Imported by: 0

Documentation

Index

Constants

View Source
const ConfigPath = "/etc/bolt/config.json"

ConfigPath is the file location to check for a config.json file

View Source
const EngineName = "Bolt Engine"

EngineName is the 'friendly' marketing name of the product

View Source
const HaltCallCommandName = "HALT_CALL"

HaltCallCommandName is the string pased to payload.nextCommand to stop all further processing of an api call

View Source
const Version = "1.1.3"

Version for bolt engine and components

Variables

This section is empty.

Functions

func BuiltinHandlers

func BuiltinHandlers(eng *Engine)

BuiltinHandlers registers the core bolt engine calls

func EngineReboot added in v1.1.3

func EngineReboot(ch, rebootChan chan bool)

EngineReboot starts the reboot process started in api.go,

func ExtractCallName

func ExtractCallName(r *http.Request) (string, error)

ExtractCallName pulls the API call name from the URL and returns the string.

func OutputError

func OutputError(w http.ResponseWriter, err *bolterror.BoltError)

OutputError writes a JSON error response to w with no other outputs params or variables

func StartEngineReboot added in v1.1.3

func StartEngineReboot()

StartEngineReboot starts the reboot proccess called from api.CheckConfig or coreHandleReboot

Types

type Context

type Context struct {
	Engine      *Engine
	RequireAuth bool
}

Context containts the variables relevant to this http request (engine, logger, etc)

type Engine

type Engine struct {
	Config     *config.Config
	ConfigPath string

	Server        *http.Server
	Mux           *http.ServeMux
	ContextNoAuth *Context
	ContextAuth   *Context

	Log      *logrus.Logger
	Requests *requestmanager.RequestManager
	Stats    *stats.Collector
	Throttle map[string]map[int]time.Time
	// contains filtered or unexported fields
}

Engine holds config info, server struct, etc for a running engine

func CreateTestEngine

func CreateTestEngine(loglevel string) *Engine

CreateTestEngine returns a fully configured engine with a special test config to be used in unit tests, etc. go ListenAndServe() must be called by the test if needed. -- DO NOT USE IN PRODUCTION CODE --

func (*Engine) CacheCallResult

func (engine *Engine) CacheCallResult(cp *commandprocess.CommandProcess) error

CacheCallResult sets the cache for an commandprocess if applicable

func (*Engine) CreateLogger

func (engine *Engine) CreateLogger()

CreateLogger sets up a logger instance with configed hooks, etc

func (*Engine) DelCacheItem

func (engine *Engine) DelCacheItem(apicall string, inputjson string) error

DelCacheItem attempts to force-delete a cached key

func (*Engine) GetCacheItem

func (engine *Engine) GetCacheItem(apicall string, inputjson string) (string, error)

GetCacheItem tries to get an item from cache if possible

func (*Engine) HandleCall

func (engine *Engine) HandleCall(reqtype int, w http.ResponseWriter, r *http.Request, hmacGroup string)

HandleCall preps and performs queing, validation, and initiates processing for an API call. reqtype is a constant which tells the engine how to handle the request (commandprocess.CallType*).

CallTypeRequest: Engine processes the API call and returns the result, however if the timeout is reached,
			 it will return the task ID so the client can retrieve the result later
CallTypeTask: Engine processes the API call, but returns the task ID immedately without waiting for the result.
CallTypeWork: Engine processes the API call with no task ID or returned results

func (*Engine) IsShutdown

func (engine *Engine) IsShutdown() bool

IsShutdown returns true if engine is in shutdown mode

func (*Engine) ListenAndServe

func (engine *Engine) ListenAndServe() error

ListenAndServe performs final configs and starts the http server listening with the config port and https certs

func (*Engine) LogDebug

func (engine *Engine) LogDebug(code string, fields log.Fields, message string)

LogDebug logs an info message with fields

func (*Engine) LogError

func (engine *Engine) LogError(code string, fields log.Fields, message string)

LogError logs an info message with fields

func (*Engine) LogFatal

func (engine *Engine) LogFatal(code string, fields log.Fields, message string)

LogFatal logs an info message with fields

func (*Engine) LogInfo

func (engine *Engine) LogInfo(code string, fields log.Fields, message string)

LogInfo logs an info message with fields

func (*Engine) LogPanic

func (engine *Engine) LogPanic(code string, fields log.Fields, message string)

LogPanic logs an info message with fields

func (*Engine) LogWarn

func (engine *Engine) LogWarn(code string, fields log.Fields, message string)

LogWarn logs an info message with fields

func (*Engine) OutputDebugForm

func (engine *Engine) OutputDebugForm(w http.ResponseWriter, r *http.Request)

OutputDebugForm spits out the debug form template for /form/

func (*Engine) OutputError

func (engine *Engine) OutputError(w http.ResponseWriter, err *bolterror.BoltError)

OutputError outputs an error message and logs it using the engine's log system

func (*Engine) OutputRequest

func (engine *Engine) OutputRequest(w http.ResponseWriter, req *commandprocess.CommandProcess, filterKeys []string)

OutputRequest filters the payload and writes a call request to w

func (*Engine) PostConfig

func (engine *Engine) PostConfig(cfg *config.Config) error

PostConfig takes the populated config and prepares auto cors, command durations, etc.

func (*Engine) SetCacheItem

func (engine *Engine) SetCacheItem(apicall string, inputjson string, value string, expiration time.Duration) error

SetCacheItem adds an item to cache, forces non-local cache use

func (*Engine) SetupCache

func (engine *Engine) SetupCache() error

SetupCache uses the current config to connect and setup a cache system

func (*Engine) Shutdown

func (engine *Engine) Shutdown() bool

Shutdown sets the engine to reject new non-core API calls, and waits for current commands to timeout or complete before exiting. Returns false if a shutdown process was already started, true otherwise

type Handler

type Handler struct {
	Context   *Context
	H         func(*Context, http.ResponseWriter, *http.Request, string) error
	HMACGroup string
}

Handler contains the context and handler function for a bolt api http request

func (Handler) ServeHTTP

func (ah Handler) ServeHTTP(w http.ResponseWriter, r *http.Request)

ServeHTTP for bolt handles security (if applicable) and logging Output mime-type defaults to application/json

type ListenerD added in v1.1.3

type ListenerD struct {
	*net.TCPListener //wraps TCPListener
	// contains filtered or unexported fields
}

ListenerD is a stoppable listener to be used when serving the bolt engine It will allow the engine to free up the port the server is bound to

func GetListenChan added in v1.1.3

func GetListenChan() *ListenerD

GetListenChan sends the stoppable listener

func NewListenerD added in v1.1.3

func NewListenerD(listener net.Listener) (*ListenerD, error)

NewListenerD builds a new listenerD

func (*ListenerD) Accept added in v1.1.3

func (listenerD *ListenerD) Accept() (net.Conn, error)

Accept accepts

func (*ListenerD) Stop added in v1.1.3

func (listenerD *ListenerD) Stop()

Stop stops the listener

Jump to

Keyboard shortcuts

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