Documentation
¶
Overview ¶
daemonPkg implements the chifra daemon command.
chifra daemon manages chifra's API server. Each of the chifra commands along with all of its options, are provided not only by the command line, but also the API server. We call this process the flame server, which is written in Go. chifra serve is an alias for the chifra daemon command.
In the future, this daemon may also manage other long-running processes such as chifra scrape and chifra monitors, but for now, it's only managing the API server.
If the default port for the API server is in use, you may change it with the --url option.
To get help for any command, please see the API documentation on our website. But, you may also run chifra --help or chifra <cmd> --help on your command line to get help.
See below for an example of converting command line options to a call to the API. There's a one-to-one correspondence between the command line tools and options and the API routes and their options.
Index ¶
- Variables
- func ContentTypeHandler(next http.Handler) http.Handler
- func CorsHandler(next http.Handler) http.Handler
- func HandleWebsockets(pool *ConnectionPool, w http.ResponseWriter, r *http.Request)
- func Logger(silent bool, inner http.Handler, name string) http.Handler
- func NewRouter(silent bool) *mux.Router
- func ResetOptions(testMode bool)
- func RespondWithError(w http.ResponseWriter, httpStatus int, err error)
- func RunDaemon(cmd *cobra.Command, args []string) error
- func RunWebsocketPool()
- func ServeDaemon(w http.ResponseWriter, r *http.Request) error
- type ConnectionPool
- type DaemonOptions
- type Message
- type MessageType
- type Route
Constants ¶
This section is empty.
Variables ¶
var OptionsHandler = http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
_ = r
addCorsHeaders(w)
})
Functions ¶
func ContentTypeHandler ¶
ContentTypeHandler sets correct Content-Type header on response
func CorsHandler ¶
CorsHandler handles CORS requests
func HandleWebsockets ¶
func HandleWebsockets(pool *ConnectionPool, w http.ResponseWriter, r *http.Request)
HandleWebsockets handles web sockets
func ResetOptions ¶
func ResetOptions(testMode bool)
func RespondWithError ¶
func RespondWithError(w http.ResponseWriter, httpStatus int, err error)
RespondWithError marshals an err into JSON and returns the bytes back to the caller httpStatus HTTP error status code
func RunDaemon ¶
RunDaemon handles the daemon command for the command line. Returns error only as per cobra.
func ServeDaemon ¶
func ServeDaemon(w http.ResponseWriter, r *http.Request) error
ServeDaemon handles the daemon command for the API. Returns an error.
Types ¶
type ConnectionPool ¶
type ConnectionPool struct {
// contains filtered or unexported fields
}
ConnectionPool is the collection of all connections
type DaemonOptions ¶
type DaemonOptions struct {
Url string `json:"url,omitempty"` // Specify the API server's url and optionally its port
Silent bool `json:"silent,omitempty"` // Disable logging (for use in SDK for example)
Globals globals.GlobalOptions `json:"globals,omitempty"` // The global options
Conn *rpc.Connection `json:"conn,omitempty"` // The connection to the RPC server
BadFlag error `json:"badFlag,omitempty"` // An error flag if needed
}
DaemonOptions provides all command options for the chifra daemon command.
func DaemonFinishParseInternal ¶
func DaemonFinishParseInternal(w io.Writer, values url.Values) *DaemonOptions
func GetDaemonOptions ¶
func GetDaemonOptions(args []string, g *globals.GlobalOptions) *DaemonOptions
GetDaemonOptions returns the options for this tool so other tools may use it.
func GetOptions ¶
func GetOptions() *DaemonOptions
func (*DaemonOptions) DaemonInternal ¶
func (opts *DaemonOptions) DaemonInternal(rCtx *output.RenderCtx) error
DaemonInternal handles the internal workings of the daemon command. Returns an error.
func (*DaemonOptions) String ¶
func (opts *DaemonOptions) String() string
String implements the Stringer interface
type Message ¶
type Message struct {
Action MessageType `json:"action"`
ID string `json:"id"`
Content string `json:"content"`
}
Message is a structure used to send messages via websockets
type MessageType ¶
type MessageType string
MessageType is a message carried in a string
const ( // CommandErrorMessage is a message send when the server encounters an error CommandErrorMessage MessageType = "command_error" // CommandOutputMessage is currently not used, but may in the future carry the actual data CommandOutputMessage MessageType = "output" // ProgressMessage is a message carried on the stderr stream ProgressMessage MessageType = "progress" )