Documentation ¶
Index ¶
- Variables
- func FindConnection(ctx Context, name, namespace string) (*models.Connection, error)
- func FindConnectionByURL(ctx Context, connectionString string) (*models.Connection, error)
- func GetConfigMapFromCache(ctx Context, namespace, name, key string) (string, error)
- func GetConnection(ctx Context, name, namespace string) (*models.Connection, error)
- func GetEnvStringFromCache(ctx Context, env string, namespace string) (string, error)
- func GetEnvValueFromCache(ctx Context, input types.EnvVar, namespace string) (string, error)
- func GetHelmValueFromCache(ctx Context, namespace, releaseName, key string) (string, error)
- func GetSecretFromCache(ctx Context, namespace, name, key string) (string, error)
- func GetServiceAccountTokenFromCache(ctx Context, namespace, serviceAccount string) (string, error)
- func HydrateConnection(ctx Context, connection *models.Connection) (*models.Connection, error)
- func HydrateConnectionByURL(ctx Context, connectionString string) (*models.Connection, error)
- func IsValidConnectionURL(connectionString string) bool
- func LoadPropertiesFromFile(ctx Context, filename string) error
- func ParsePropertiesFile(filename string) (map[string]string, error)
- func SetLocalProperty(property, value string)
- func UpdateProperties(ctx Context, props map[string]string) error
- func UpdateProperty(ctx Context, key, value string) error
- type Context
- func (k Context) Agent() *models.Agent
- func (k Context) ClearCache()
- func (k Context) Counter(name string, labels ...string) Counter
- func (k Context) DB() *gorm.DB
- func (k Context) Fast() Context
- func (k Context) FastDB() *gorm.DB
- func (k Context) Gauge(name string, labels ...string) Gauge
- func (k Context) GetAnnotations() map[string]string
- func (k Context) GetConfigMapFromCache(namespace, name, key string) (string, error)
- func (ctx Context) GetConnection(name, namespace string) (*models.Connection, error)
- func (k Context) GetEnvStringFromCache(env string, namespace string) (string, error)
- func (k Context) GetEnvValueFromCache(input types.EnvVar, namespace string) (string, error)
- func (k Context) GetLabels() map[string]string
- func (k Context) GetName() string
- func (k Context) GetNamespace() string
- func (k Context) GetObjectMeta() metav1.ObjectMeta
- func (k Context) GetSecretFromCache(namespace, name, key string) (string, error)
- func (k Context) Histogram(name string, buckets []float64, labels ...string) Histogram
- func (k Context) HydrateConnection(connection *models.Connection) (*models.Connection, error)
- func (k Context) HydrateConnectionByURL(connectionString string) (*models.Connection, error)
- func (k Context) IsTracing() bool
- func (k *Context) Kommons() *kommons.Client
- func (k *Context) Kubernetes() kubernetes.Interface
- func (k Context) NewStructTemplater(vals map[string]any, requiredTag string, funcs map[string]any) gomplate.StructTemplater
- func (k Context) Pool() *pgxpool.Pool
- func (k Context) Properties() Properties
- func (k Context) RunTemplate(t gomplate.Template, env map[string]any) (string, error)
- func (k Context) StartSpan(name string) (Context, trace.Span)
- func (k Context) Topology() any
- func (k Context) User() *models.Person
- func (k Context) WithAgent(agent models.Agent) Context
- func (k Context) WithAnyValue(key, val any) Context
- func (k Context) WithDB(db *gorm.DB, pool *pgxpool.Pool) Context
- func (k Context) WithDBLogLevel(level string) Context
- func (k Context) WithDeadline(deadline time.Time) (Context, gocontext.CancelFunc)
- func (k Context) WithDebug() Context
- func (k Context) WithKommons(client *kommons.Client) Context
- func (k Context) WithKubernetes(client kubernetes.Interface) Context
- func (k Context) WithName(name string) Context
- func (k Context) WithNamespace(namespace string) Context
- func (k Context) WithObject(object metav1.ObjectMeta) Context
- func (k Context) WithTimeout(timeout time.Duration) (Context, gocontext.CancelFunc)
- func (k Context) WithTopology(topology any) Context
- func (k Context) WithTrace() Context
- func (k Context) WithUser(user *models.Person) Context
- func (k Context) WithoutName() Context
- func (k Context) WithoutTracing() Context
- func (k Context) Wrap(ctx gocontext.Context) Context
- type Counter
- type Gauge
- type Gormable
- type Histogram
- type Poolable
- type Properties
Constants ¶
This section is empty.
Variables ¶
var (
ErrNotFound = errors.New("NOT_FOUND")
)
var LatencyBuckets = []float64{ float64(10 * time.Millisecond), float64(50 * time.Millisecond), float64(100 * time.Millisecond), float64(500 * time.Millisecond), float64(1 * time.Second), float64(5 * time.Second), float64(30 * time.Second), float64(1 * time.Minute), float64(5 * time.Minute), float64(30 * time.Minute), }
var Local map[string]string
var TemplateFuncs = make(map[string]func(Context) any)
Functions ¶
func FindConnection ¶ added in v1.0.207
func FindConnection(ctx Context, name, namespace string) (*models.Connection, error)
FindConnection returns the connection with the given type and name
func FindConnectionByURL ¶ added in v1.0.207
func FindConnectionByURL(ctx Context, connectionString string) (*models.Connection, error)
FindConnectionByURL retrieves a connection from the given connection string. The connection string is expected to be in one of the following forms:
- connection://<namespace>/<name> or connection://<name>
- the UUID of the connection.
func GetConfigMapFromCache ¶ added in v1.0.207
func GetConnection ¶ added in v1.0.207
func GetConnection(ctx Context, name, namespace string) (*models.Connection, error)
func GetEnvStringFromCache ¶ added in v1.0.207
func GetEnvValueFromCache ¶ added in v1.0.207
func GetHelmValueFromCache ¶ added in v1.0.239
func GetSecretFromCache ¶ added in v1.0.207
func GetServiceAccountTokenFromCache ¶ added in v1.0.233
func HydrateConnection ¶ added in v1.0.207
func HydrateConnection(ctx Context, connection *models.Connection) (*models.Connection, error)
Create a cache with a default expiration time of 5 minutes, and which purges expired items every 10 minutes var connectionCache = cache.New(5*time.Minute, 10*time.Minute)
func HydrateConnectionByURL ¶ added in v1.0.216
func HydrateConnectionByURL(ctx Context, connectionString string) (*models.Connection, error)
HydrateConnectionByURL retrieves a connection from the given connection string. The connection string is expected to be in one of the following forms:
- connection://<namespace>/<name> or connection://<name>
- the UUID of the connection.
func IsValidConnectionURL ¶ added in v1.0.207
func LoadPropertiesFromFile ¶ added in v1.0.259
func ParsePropertiesFile ¶ added in v1.0.259
func SetLocalProperty ¶ added in v1.0.310
func SetLocalProperty(property, value string)
func UpdateProperties ¶ added in v1.0.259
func UpdateProperty ¶ added in v1.0.259
Types ¶
type Context ¶
func New ¶ added in v1.0.253
func New(opts ...commons.ContextOptions) Context
func NewContext ¶
func NewContext(baseCtx gocontext.Context, opts ...commons.ContextOptions) Context
func (Context) ClearCache ¶ added in v1.0.250
func (k Context) ClearCache()
func (Context) FastDB ¶ added in v1.0.254
FastDB returns a db suitable for high-performance usage, with limited logging and tracing
func (Context) GetAnnotations ¶
func (Context) GetConfigMapFromCache ¶
func (Context) GetConnection ¶ added in v1.0.207
func (ctx Context) GetConnection(name, namespace string) (*models.Connection, error)
func (Context) GetEnvStringFromCache ¶
func (Context) GetEnvValueFromCache ¶
func (Context) GetNamespace ¶
func (Context) GetObjectMeta ¶
func (k Context) GetObjectMeta() metav1.ObjectMeta
func (Context) GetSecretFromCache ¶
func (Context) HydrateConnection ¶
func (k Context) HydrateConnection(connection *models.Connection) (*models.Connection, error)
func (Context) HydrateConnectionByURL ¶ added in v1.0.216
func (k Context) HydrateConnectionByURL(connectionString string) (*models.Connection, error)
func (*Context) Kubernetes ¶
func (k *Context) Kubernetes() kubernetes.Interface
func (Context) NewStructTemplater ¶ added in v1.0.345
func (Context) Properties ¶ added in v1.0.245
func (k Context) Properties() Properties
Properties returns a cached map of properties
func (Context) RunTemplate ¶ added in v1.0.343
func (Context) WithAgent ¶ added in v1.0.295
WithAgent sets the current session's agent in the context
func (Context) WithAnyValue ¶ added in v1.0.276
WithAnyValue is a wrapper around WithValue
func (Context) WithDBLogLevel ¶ added in v1.0.250
func (Context) WithDeadline ¶ added in v1.0.307
func (Context) WithKommons ¶ added in v1.0.202
func (Context) WithKubernetes ¶
func (k Context) WithKubernetes(client kubernetes.Interface) Context
func (Context) WithNamespace ¶ added in v1.0.197
func (Context) WithObject ¶
func (k Context) WithObject(object metav1.ObjectMeta) Context
func (Context) WithTimeout ¶ added in v1.0.197
func (Context) WithTopology ¶ added in v1.0.276
func (Context) WithoutName ¶ added in v1.0.307
func (Context) WithoutTracing ¶ added in v1.0.325
type Counter ¶ added in v1.0.317
type Counter struct { Context Context Name string Labels map[string]string Counter *prometheus.CounterVec }
type Gauge ¶ added in v1.0.419
type Histogram ¶ added in v1.0.317
type Histogram struct { Context Context Name string Histogram *prometheus.HistogramVec Labels map[string]string }
type Properties ¶ added in v1.0.307
func (Properties) Off ¶ added in v1.0.307
func (p Properties) Off(key string) bool
func (Properties) On ¶ added in v1.0.307
func (p Properties) On(key string) bool