common

package
v0.1.11 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 4, 2025 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const (
	OptionsKey                        ContextKey = "snmcp-options"
	AnnotationStreamNativeCloudEngine            = "cloud.streamnative.io/engine"
	KeyPrefix                                    = "snmcp-token"
	TokenRefreshWindow                           = 5 * time.Minute
)

Variables

This section is empty.

Functions

func ConvertToMapInterface

func ConvertToMapInterface(m map[string]string) map[string]interface{}

func ConvertToMapString

func ConvertToMapString(m map[string]interface{}) map[string]string

func GetEngineType

GetEngineType returns the Pulsar cluster is an Ursa engine or a Classic engine

func GetOptions

func GetOptions(ctx context.Context) *config.Options

func HasCachedValidToken

func HasCachedValidToken(cachedGrant *auth.AuthorizationGrant) (bool, error)

func IsClusterAvailable

IsClusterAvailable checks if a PulsarCluster is available (ready)

func IsInstanceValid

IsInstanceValid checks if PulsarInstance has valid OAuth2 authentication configuration

func IsTokenAboutToExpire

func IsTokenAboutToExpire(cachedGrant *auth.AuthorizationGrant, window time.Duration) (bool, error)

func OptionalParam

func OptionalParam[T any](arguments map[string]interface{}, paramName string) (T, bool)

Helper function to get an optional parameter from the request

func OptionalParamArray

func OptionalParamArray[T any](arguments map[string]interface{}, paramName string) ([]T, bool)

func OptionalParamConfigs

func OptionalParamConfigs(arguments map[string]interface{}, paramName string) ([]string, bool)

OptionalParamConfigs gets an optional parameter as a list of key=value strings

func OptionalParamObject

func OptionalParamObject(arguments map[string]interface{}, name string) (map[string]interface{}, bool)

func ParseMessageConfigs

func ParseMessageConfigs(configs []string) (map[string]*string, error)

ParseMessageConfigs parses a list of key=value strings into a map

func RequiredParam

func RequiredParam[T comparable](arguments map[string]interface{}, p string) (T, error)

RequiredParam is a helper function that can be used to fetch a requested parameter from the request. It does the following checks: 1. Checks if the parameter is present in the request. 2. Checks if the parameter is of the expected type. 3. Checks if the parameter is not empty, i.e: non-zero value

func RequiredParamArray

func RequiredParamArray[T any](arguments map[string]interface{}, paramName string) ([]T, error)

Helper function to get a required array parameter from the request

func RequiredParamObject

func RequiredParamObject(arguments map[string]interface{}, name string) (map[string]interface{}, error)

RequiredParamObject gets a required object parameter from the request

Types

type ContextKey

type ContextKey string

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL