Documentation ¶
Overview ¶
Package cyfe implements the basic Push API for Cyfe in Go according to https://www.cyfe.com/api It is important to remember that no calls will actually be made if CYFE_ENV is not set to production. See Push() for more information
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type APIReturn ¶
type APIReturn struct { StatusCode int `json:"statusCode"` Status string `json:"status"` Message string `json:"message"` }
APIReturn is the success return from a successful push
func Push ¶
func Push(request *PushSendRequest) (ret APIReturn, err error)
Push actually makes the push request. NOTE: If the CYFE_ENV environment variable is not set to production, the request is NOT actually sent. This is to prevent accidentally sending metrics in test or development environments.
type PushOptions ¶
type PushOptions struct { // ReplaceInstead toggles whether a new push adds to the value (false, default) or replaces the value (true) ReplaceInstead bool Color string Type string IsCumulative bool DisplayAverages bool OverwriteTotal bool OverwriteComparison bool // IsBad specifies if a higher value for this metric is "bad" (see reverse in docs) IsBad bool IsUpsideDownGraph bool UnsyncYAxis bool YAxisMin string YAxisMax string YAxisShow bool ShowLabel bool // Token is available to override a token read from the end point Token string }
PushOptions are a set of options for a specific Push request. Sane defaults are used (hence why the names differ than in the Cyfe API docs) so that, for example, false equates to the default behavior for instantiation
type PushSendRequest ¶
type PushSendRequest struct { Data []map[string]string `json:"data,omitempty"` OnDuplicate *map[string]string `json:"onduplicate,omitempty"` Color *map[string]string `json:"color,omitempty"` Type *map[string]string `json:"type,omitempty"` Cumulative *map[string]string `json:"cumulative,omitempty"` Average *map[string]string `json:"average,omitempty"` Total *map[string]string `json:"total,omitempty"` Comparison *map[string]string `json:"comparison,omitempty"` Reverse *map[string]string `json:"reverse,omitempty"` ReverseGraph *map[string]string `json:"reversegraph,omitempty"` YAxis *map[string]string `json:"yaxis,omitempty"` YAxisMin *map[string]string `json:"yaxismin,omitempty"` YAxisMax *map[string]string `json:"yaxismax,omitempty"` YAxisShow *map[string]string `json:"yaxisshow,omitempty"` LabelShow *map[string]string `json:"labelshow,omitempty"` ChartToken string `json:"-"` }
PushSendRequest is the formatted request to be sent to the Cyfe server
func CreateDefaultSendRequest ¶
func CreateDefaultSendRequest(metricLabel string) (send *PushSendRequest)
CreateDefaultSendRequest initializes sane defaults for the send request. Right now it does nothing, but could be a place to override basics if needed
func Prepare ¶
func Prepare(metricLabel, metricValue, keyLabel, keyValue string, options *PushOptions) (request *PushSendRequest, err error)
Prepare prepares a metric to be sent by filling out all of the options and formatting the data. Currently, you can only push one metric per call. A future improvement would be to allow multiple metricLabel/metricValue pairs. If keyLabel is empty or keyLabel is date AND keyValue is empty, the keyLabel will be set to Date (intentional capitalization as per the docs) and the current UTC timestamp