Documentation ¶
Index ¶
- Constants
- Variables
- type APIArray
- func (a *APIArray) AddEntry(key string, entry APINavigatable)
- func (a *APIArray) Call(params url.Values) (string, error)
- func (a *APIArray) Get(path string) (APINavigatable, error)
- func (a *APIArray) HumanReadable(indent string) ([]byte, error)
- func (a *APIArray) MarshalJSON() ([]byte, error)
- func (a *APIArray) RemoveEntry(key string)
- func (a *APIArray) Update() error
- type APICallbackEntry
- func (c *APICallbackEntry) Call(values url.Values) (string, error)
- func (c *APICallbackEntry) Get(path string) (APINavigatable, error)
- func (c *APICallbackEntry) HumanReadable(indent string) ([]byte, error)
- func (c *APICallbackEntry) MarshalJSON() ([]byte, error)
- func (c *APICallbackEntry) Update() error
- type APICallbackFunc
- type APIDataEntry
- type APIEncodable
- type APIFloat
- type APIKeyValue
- func (d *APIKeyValue) Call(params url.Values) (string, error)
- func (d *APIKeyValue) Get(string) (APINavigatable, error)
- func (d *APIKeyValue) HumanReadable(indent string) ([]byte, error)
- func (d *APIKeyValue) MarshalJSON() ([]byte, error)
- func (d *APIKeyValue) RemoveEntry(key string, entry APIEncodable)
- func (d *APIKeyValue) SetEntry(key string, entry APIEncodable)
- func (d *APIKeyValue) Update() error
- type APINavigatable
- type APINode
- func (n *APINode) Call(url.Values) (string, error)
- func (n *APINode) Get(path string) (APINavigatable, error)
- func (n *APINode) HumanReadable(indent string) ([]byte, error)
- func (n *APINode) MarshalJSON() ([]byte, error)
- func (n *APINode) RemoveEntry(path string)
- func (n *APINode) SetEntry(path string, entry APINavigatable)
- func (n *APINode) Update() error
- type APINumber
- type APIString
- type Client
- type Config
- type ErrUnknown
- type ErrorResponse
- type PongResponse
- type ReloadResponse
- type Response
- type Server
- type V1Client
Constants ¶
const APIIndentation = " "
APIIndentation is a single indentation to be used in HumanReadable calls on API entries
Variables ¶
var ( // ErrNotImplemented is an API error when the call is not implemented ErrNotImplemented = errors.New("Not Implemented") // ErrNotFound is an API error when the requested information was not found ErrNotFound = errors.New("Not Found") )
var APINull = apiNull{}
APINull represents a null value
var ( // DefaultAdminBind is the default bind address to use when admin is enabled // and can be modified during init() DefaultAdminBind = "tcp:127.0.0.1:12345" )
Functions ¶
This section is empty.
Types ¶
type APIArray ¶
type APIArray struct {
// contains filtered or unexported fields
}
APIArray represents an array of entries in the API accessible through a primary key
func (*APIArray) AddEntry ¶
func (a *APIArray) AddEntry(key string, entry APINavigatable)
AddEntry a new array entry
func (*APIArray) Get ¶
func (a *APIArray) Get(path string) (APINavigatable, error)
Get returns an entry using it's primary key name or row number
func (*APIArray) HumanReadable ¶
HumanReadable returns the APIArray as a string
func (*APIArray) MarshalJSON ¶
MarshalJSON returns the APIArray in JSON form
func (*APIArray) RemoveEntry ¶
RemoveEntry removes an array entry
type APICallbackEntry ¶
type APICallbackEntry struct {
// contains filtered or unexported fields
}
APICallbackEntry is an entry that provides an API callback
func NewAPICallbackEntry ¶
func NewAPICallbackEntry(f APICallbackFunc) *APICallbackEntry
NewAPICallbackEntry creates a new APICallbackEntry from an APICallbackFunc
func (*APICallbackEntry) Call ¶
func (c *APICallbackEntry) Call(values url.Values) (string, error)
Call runs the callback function
func (*APICallbackEntry) Get ¶
func (c *APICallbackEntry) Get(path string) (APINavigatable, error)
Get always returns nil for an APICallbackEntry
func (*APICallbackEntry) HumanReadable ¶
func (c *APICallbackEntry) HumanReadable(indent string) ([]byte, error)
HumanReadable returns the APICallbackEntry as a string
func (*APICallbackEntry) MarshalJSON ¶
func (c *APICallbackEntry) MarshalJSON() ([]byte, error)
MarshalJSON returns the APICallbackEntry in JSON form
func (*APICallbackEntry) Update ¶
func (c *APICallbackEntry) Update() error
Update does nothing for an APICallbackEntry
type APICallbackFunc ¶
APICallbackFunc is a function that can be called by the API
type APIDataEntry ¶
type APIDataEntry struct {
// contains filtered or unexported fields
}
APIDataEntry wraps an APIEncodable so it can be used as an APINavigatable It stubs the navigation methods so they are no-ops
func NewAPIDataEntry ¶
func NewAPIDataEntry(a APIEncodable) *APIDataEntry
NewAPIDataEntry creates a new APIDataEntry from an APIEncodable
func (*APIDataEntry) Call ¶
func (d *APIDataEntry) Call(url.Values) (string, error)
Call always returns ErrNotImplemented for an APIDataEntry
func (*APIDataEntry) Get ¶
func (d *APIDataEntry) Get(path string) (APINavigatable, error)
Get always returns nil for an APIDataEntry
func (*APIDataEntry) HumanReadable ¶
func (d *APIDataEntry) HumanReadable(indent string) ([]byte, error)
HumanReadable returns the APIDataEntry as a string
func (*APIDataEntry) MarshalJSON ¶
func (d *APIDataEntry) MarshalJSON() ([]byte, error)
MarshalJSON returns the APIDataEntry in JSON form
func (*APIDataEntry) Update ¶
func (d *APIDataEntry) Update() error
Update does nothing for an APIDataEntry
type APIEncodable ¶
type APIEncodable interface { // HumanReadable returns the entry as a string in human-readable form // If it contains multiple lines, it should prefix each line with the indent // string passes to it. If the call to HumanReadable needs to recurse into // another HumanReadable call it should add APIIndentation to the indent // string, and check the returned string for new lines and render accordingly HumanReadable(indent string) ([]byte, error) }
APIEncodable is an encodable entry in the API, which can be a navigatable entry or just a piece of data
type APIKeyValue ¶
type APIKeyValue struct {
// contains filtered or unexported fields
}
APIKeyValue represents a set of data
func (*APIKeyValue) Call ¶
func (d *APIKeyValue) Call(params url.Values) (string, error)
Call an API
func (*APIKeyValue) Get ¶
func (d *APIKeyValue) Get(string) (APINavigatable, error)
Get always returns nil for an APIKeyValue as it is not navigatable
func (*APIKeyValue) HumanReadable ¶
func (d *APIKeyValue) HumanReadable(indent string) ([]byte, error)
HumanReadable returns the APIKeyValue as a string
func (*APIKeyValue) MarshalJSON ¶
func (d *APIKeyValue) MarshalJSON() ([]byte, error)
MarshalJSON returns the APIKeyValue data in JSON form
func (*APIKeyValue) RemoveEntry ¶
func (d *APIKeyValue) RemoveEntry(key string, entry APIEncodable)
RemoveEntry removes a data entry
func (*APIKeyValue) SetEntry ¶
func (d *APIKeyValue) SetEntry(key string, entry APIEncodable)
SetEntry sets a new data entry
func (*APIKeyValue) Update ¶
func (d *APIKeyValue) Update() error
Update ensures the data we have is up to date - should be overriden by users if required to keep the contents up to date on each request
type APINavigatable ¶
type APINavigatable interface { APIEncodable // children Get(name string) (APINavigatable, error) Call(params url.Values) (string, error) Update() error }
APINavigatable is a navigatable entry in the API
type APINode ¶
type APINode struct {
// contains filtered or unexported fields
}
APINode acts like a directory in the API, containing mappings from names to status information of various types
func (*APINode) Get ¶
func (n *APINode) Get(path string) (APINavigatable, error)
Get the child entry with the specified name
func (*APINode) HumanReadable ¶
HumanReadable returns the entire path structures in human-readable form
func (*APINode) MarshalJSON ¶
MarshalJSON returns the entire path structures in JSON form
func (*APINode) RemoveEntry ¶
RemoveEntry removes a path entry
func (*APINode) SetEntry ¶
func (n *APINode) SetEntry(path string, entry APINavigatable)
SetEntry adds a new path entry with the given name
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client provides an interface for accessing the REST API with pretty responses
func (*Client) RemoteVersion ¶
RemoteVersion returns the version of the remotely connected Log Courier
type Config ¶
type Config struct { Enabled bool `config:"enabled"` Bind string `config:"listen address"` // contains filtered or unexported fields }
Config holds the admin configuration It also holds the root of the API which pipeline segments can attach to in order to provide action functions and status returns
func (*Config) InitDefaults ¶
func (c *Config) InitDefaults()
InitDefaults initialises default values
func (*Config) SetEntry ¶
func (c *Config) SetEntry(path string, entry APINavigatable)
SetEntry sets a new root API entry
type ErrUnknown ¶
type ErrUnknown error
ErrUnknown represents a successful request where Log Courier returned an error, as opposed to an error processing a request
type ErrorResponse ¶
type ErrorResponse struct {
Message string
}
func (*ErrorResponse) Error ¶
func (e *ErrorResponse) Error() string
type PongResponse ¶
type PongResponse struct { }
type ReloadResponse ¶
type ReloadResponse struct { }
type Server ¶
type Server struct { core.PipelineSegment core.PipelineConfigReceiver // contains filtered or unexported fields }
Server provides a REST interface for administration
type V1Client ¶
type V1Client struct {
// contains filtered or unexported fields
}
V1Client is a client compatible with Log Courier 1.x
func NewV1Client ¶
NewV1Client returns a new admin client compatible with Log Courier 1.x
func (*V1Client) FetchSnapshot ¶
FetchSnapshot requests a status snapshot from Log Courier