Documentation
¶
Index ¶
- Constants
- Variables
- func CreateSubscribeRequest(cfg *types.SubscriptionConfig, tc *types.TargetConfig, defaultEncoding string) (*gnmi.SubscribeRequest, error)
- func GetConfigMaps(s store.Store[any]) (map[string]*types.TargetConfig, map[string]map[string]any, ...)
- func NewTokenProvider(clientID, clientSecret, tokenURL string) sarama.AccessTokenProvider
- func RecoverMiddleware(logger func() *slog.Logger) mux.MiddlewareFunc
- func SetSaramaLoggerOnce(logger *slog.Logger, level slog.Level)
- func SubscriptionConfigToNotification(sub *types.SubscriptionConfig, e gnmi.Encoding) *gnmi.Notification
- func SubscriptionOpts(sc *types.SubscriptionConfig, tc *types.TargetConfig, defaultEncoding string) ([]api.GNMIOption, error)
- func TargetConfigToNotification(tc *types.TargetConfig, e gnmi.Encoding) *gnmi.Notification
- func ValidateSubscriptionConfig(sc *types.SubscriptionConfig) error
- type RegisteredExtensions
- type TokenProvider
Constants ¶
const ( SubscriptionMode_STREAM = "STREAM" SubscriptionMode_ONCE = "ONCE" SubscriptionMode_POLL = "POLL" SubscriptionStreamMode_TARGET_DEFINED = "TARGET_DEFINED" SubscriptionStreamMode_ON_CHANGE = "ON_CHANGE" SubscriptionStreamMode_SAMPLE = "SAMPLE" )
Variables ¶
var ErrConfig = errors.New("config error")
Functions ¶
func CreateSubscribeRequest ¶ added in v0.42.1
func CreateSubscribeRequest(cfg *types.SubscriptionConfig, tc *types.TargetConfig, defaultEncoding string) (*gnmi.SubscribeRequest, error)
func GetConfigMaps ¶ added in v0.43.0
func NewTokenProvider ¶
func NewTokenProvider(clientID, clientSecret, tokenURL string) sarama.AccessTokenProvider
func RecoverMiddleware ¶
func RecoverMiddleware(logger func() *slog.Logger) mux.MiddlewareFunc
RecoverMiddleware returns an HTTP middleware that recovers from panics in the wrapped handler. The panic is logged with the request method, path and matched route template, and a `500 Internal Server Error` JSON response is sent when the handler had not started writing a response yet.
Without it, net/http recovers the panic per connection: the client gets a reset connection with no status, and a handler that panics while holding a lock leaves it held.
The http.ErrAbortHandler sentinel is re-panicked, as net/http expects. logger is resolved per request so it may be nil until the server starts.
func SetSaramaLoggerOnce ¶ added in v0.46.0
SetSaramaLoggerOnce configures Sarama's process-wide logger once. Sarama exposes this as a global variable, so kafka inputs and outputs must coordinate through the same sync.Once to avoid racing assignments during startup.
func SubscriptionConfigToNotification ¶
func SubscriptionConfigToNotification(sub *types.SubscriptionConfig, e gnmi.Encoding) *gnmi.Notification
SubscriptionConfigToNotification converts a subscription configuration to a gNMI notification under the `gnmic` origin, in the requested encoding. Only JSON and JSON_IETF encodings are supported.
func SubscriptionOpts ¶ added in v0.42.1
func SubscriptionOpts(sc *types.SubscriptionConfig, tc *types.TargetConfig, defaultEncoding string) ([]api.GNMIOption, error)
func TargetConfigToNotification ¶
func TargetConfigToNotification(tc *types.TargetConfig, e gnmi.Encoding) *gnmi.Notification
TargetConfigToNotification converts a target configuration to a gNMI notification under the `gnmic` origin, in the requested encoding. It is used by the gNMI server(s) to reply to Get requests with origin=gnmic and path elem `targets`.
func ValidateSubscriptionConfig ¶ added in v0.48.0
func ValidateSubscriptionConfig(sc *types.SubscriptionConfig) error
ValidateSubscriptionConfig reports semantic errors in a subscription config without modifying it. An empty mode, stream-mode or encoding is accepted: those take their default value when the subscribe request is built.
Types ¶
type RegisteredExtensions ¶ added in v0.44.0
func ParseRegisteredExtensions ¶ added in v0.44.0
func ParseRegisteredExtensions(pairs []string) (RegisteredExtensions, error)
type TokenProvider ¶
type TokenProvider struct {
// contains filtered or unexported fields
}
TokenProvider is a simple struct that implements sarama.AccessTokenProvider.
func (*TokenProvider) Token ¶
func (t *TokenProvider) Token() (*sarama.AccessToken, error)