Documentation
¶
Overview ¶
Copyright © 2025 Rangertaha <rangertaha@gmail.com>
Copyright © 2025 Rangertaha <rangertaha@gmail.com>
Copyright © 2025 Rangertaha <rangertaha@gmail.com>
Copyright © 2025 Rangertaha <rangertaha@gmail.com>
Index ¶
Constants ¶
View Source
const ( DefaultName = "ares-client" ClientURL = nats.DefaultURL NomadURL = "" )
View Source
const ( CONFIG_FILENAME = "config.hcl" DefaultSubject = "ares.cmd" )
View Source
const ( KVTypeString = "string" KVTypeInt = "int" KVTypeFloat = "float" KVTypeBool = "bool" )
View Source
const YYYYMMDD = "2006/01/02"
Variables ¶
View Source
var CtxFunctions *hcl.EvalContext = &hcl.EvalContext{ Functions: map[string]function.Function{ "seconds": SecondsFunc, "minutes": MinutesFunc, "hours": HoursFunc, "days": DaysFunc, "date": DateFunc, }, }
View Source
var DateFunc = function.New(&function.Spec{ Description: "Returns a date in int64 format", Params: []function.Parameter{ { Name: "date", Type: cty.String, AllowDynamicType: true, }, }, Type: function.StaticReturnType(cty.Number), Impl: func(args []cty.Value, retType cty.Type) (cty.Value, error) { var date string if err := gocty.FromCtyValue(args[0], &date); err != nil { return cty.UnknownVal(cty.String), err } t, err := time.Parse(YYYYMMDD, date) if err != nil { return cty.UnknownVal(cty.String), err } return cty.NumberIntVal(t.Unix()), nil }, })
View Source
var DaysFunc = function.New(&function.Spec{ Description: "Returns the given hours", Params: []function.Parameter{ { Name: "num", Type: cty.Number, AllowDynamicType: true, }, }, Type: function.StaticReturnType(cty.Number), Impl: func(args []cty.Value, retType cty.Type) (cty.Value, error) { var days int64 if err := gocty.FromCtyValue(args[0], &days); err != nil { return cty.UnknownVal(cty.String), err } return cty.NumberIntVal(int64(time.Duration(days) * (time.Hour * 24))), nil }, })
View Source
var ( //go:embed config.hcl DefaultConfigBytes []byte )
View Source
var HoursFunc = function.New(&function.Spec{ Description: "Returns the given hours", Params: []function.Parameter{ { Name: "num", Type: cty.Number, AllowDynamicType: true, }, }, Type: function.StaticReturnType(cty.Number), Impl: func(args []cty.Value, retType cty.Type) (cty.Value, error) { var hours int64 if err := gocty.FromCtyValue(args[0], &hours); err != nil { return cty.UnknownVal(cty.String), err } return cty.NumberIntVal(int64(time.Duration(hours) * time.Hour)), nil }, })
View Source
var MinutesFunc = function.New(&function.Spec{ Description: "Returns the given minutes", Params: []function.Parameter{ { Name: "num", Type: cty.Number, AllowDynamicType: true, }, }, Type: function.StaticReturnType(cty.Number), Impl: func(args []cty.Value, retType cty.Type) (cty.Value, error) { var minutes int64 if err := gocty.FromCtyValue(args[0], &minutes); err != nil { return cty.UnknownVal(cty.String), err } return cty.NumberIntVal(int64(time.Duration(minutes) * time.Minute)), nil }, })
View Source
var SecondsFunc = function.New(&function.Spec{ Description: "Returns the given seconds", Params: []function.Parameter{ { Name: "num", Type: cty.Number, AllowDynamicType: true, }, }, Type: function.StaticReturnType(cty.Number), Impl: func(args []cty.Value, retType cty.Type) (cty.Value, error) { var seconds int64 if err := gocty.FromCtyValue(args[0], &seconds); err != nil { return cty.UnknownVal(cty.String), err } return cty.NumberIntVal(int64(time.Duration(seconds) * time.Second)), nil }, })
Functions ¶
func DefaultConfig ¶
func FileOption ¶
Types ¶
type Broker ¶
type ClusterOpts ¶
type ClusterOpts struct{}
type Config ¶
type Config struct {
Debug bool `hcl:"debug,optional"`
Version string `hcl:"version,optional"`
Tags Tags `hcl:"tags,optional"`
Broker *Broker `hcl:"broker,block"`
}
type Credentials ¶
type Plugin ¶
type Plugin struct {
Id string `hcl:"name,label"`
Summary string `hcl:"summary,optional"`
// Timing
Interval time.Duration `hcl:"interval,optional"`
Resolution time.Duration `hcl:"resolusion,optional"`
Precision time.Duration `hcl:"precision,optional"`
Window time.Duration `hcl:"window,optional"`
Tags Tags `hcl:"tags,optional"`
Creds []Credentials `hcl:"credentials,optional"`
KeyValues []KeyValue `hcl:"settings,optional"`
}
Click to show internal directories.
Click to hide internal directories.