Documentation ¶
Index ¶
- Constants
- func BuiltinHandlers(eng *Engine)
- func EngineReboot(ch, rebootChan chan bool)
- func ExtractCallName(r *http.Request) (string, error)
- func OutputError(w http.ResponseWriter, err *bolterror.BoltError)
- func StartEngineReboot()
- type Context
- type Engine
- func (engine *Engine) CacheCallResult(cp *commandprocess.CommandProcess) error
- func (engine *Engine) CreateLogger()
- func (engine *Engine) DelCacheItem(apicall string, inputjson string) error
- func (engine *Engine) GetCacheItem(apicall string, inputjson string) (string, error)
- func (engine *Engine) HandleCall(reqtype int, w http.ResponseWriter, r *http.Request, hmacGroup string)
- func (engine *Engine) IsShutdown() bool
- func (engine *Engine) ListenAndServe() error
- func (engine *Engine) LogDebug(code string, fields log.Fields, message string)
- func (engine *Engine) LogError(code string, fields log.Fields, message string)
- func (engine *Engine) LogFatal(code string, fields log.Fields, message string)
- func (engine *Engine) LogInfo(code string, fields log.Fields, message string)
- func (engine *Engine) LogPanic(code string, fields log.Fields, message string)
- func (engine *Engine) LogWarn(code string, fields log.Fields, message string)
- func (engine *Engine) OutputDebugForm(w http.ResponseWriter, r *http.Request)
- func (engine *Engine) OutputError(w http.ResponseWriter, err *bolterror.BoltError)
- func (engine *Engine) OutputRequest(w http.ResponseWriter, req *commandprocess.CommandProcess, filterKeys []string)
- func (engine *Engine) PostConfig(cfg *config.Config) error
- func (engine *Engine) SetCacheItem(apicall string, inputjson string, value string, expiration time.Duration) error
- func (engine *Engine) SetupCache() error
- func (engine *Engine) Shutdown() bool
- type Handler
- type ListenerD
Constants ¶
const ConfigPath = "/etc/bolt/config.json"
ConfigPath is the file location to check for a config.json file
const EngineName = "Bolt Engine"
EngineName is the 'friendly' marketing name of the product
const HaltCallCommandName = "HALT_CALL"
HaltCallCommandName is the string pased to payload.nextCommand to stop all further processing of an api call
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 ¶
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 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 ¶
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 ¶
DelCacheItem attempts to force-delete a cached key
func (*Engine) GetCacheItem ¶
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 ¶
IsShutdown returns true if engine is in shutdown mode
func (*Engine) ListenAndServe ¶
ListenAndServe performs final configs and starts the http server listening with the config port and https certs
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 ¶
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 ¶
SetupCache uses the current config to connect and setup a cache system
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
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
NewListenerD builds a new listenerD