tools

package
v5.3.1 Latest Latest
Warning

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

Go to latest
Published: Apr 8, 2024 License: Apache-2.0 Imports: 29 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CheckPlainConfigKeys

func CheckPlainConfigKeys(defaults map[string]any, allKeys []string)

CheckPlainConfigKeys warns users about unknown keys in the configuration. It does not include warnings about some arrays we have in the configuration - like namespaces or proxies configuration. Those are checked separately on decoding.

func DecodeSlice added in v5.3.1

func DecodeSlice(v *viper.Viper, dst any, key string) []byte

func DecoderConfig

func DecoderConfig(output any) *mapstructure.DecoderConfig

DecoderConfig returns default mapstructure.DecoderConfig with support of time.Duration values & string slices & Duration

func ErrorMessageFromConfigError

func ErrorMessageFromConfigError(err error, configPath string) string

ErrorMessageFromConfigError tries building a more human-friendly error from a configuration error. At the moment we can additionally extract JSON syntax error line and column. Related issue: https://github.com/golang/go/issues/43513.

func FindUnknownKeys

func FindUnknownKeys[T any](jsonMap map[string]any, data T) []string

FindUnknownKeys returns a list of keys from map not existing in struct JSON tags.

func GenerateConfig

func GenerateConfig(f string) error

GenerateConfig generates configuration file at provided path.

func GetLogAddresses

func GetLogAddresses(addresses []string) string

GetLogAddresses returns a string with addresses (concatenated with comma) with password stripped from each address.

func MakeTLSConfig

func MakeTLSConfig(v ConfigGetter, keyPrefix string, readFile ReadFileFunc) (*tls.Config, error)

MakeTLSConfig constructs a tls.Config instance using the given configuration scoped under key prefix.

func MapStringString added in v5.0.2

func MapStringString(v *viper.Viper, key string) (map[string]string, error)

func NodeWithMemoryEngine

func NodeWithMemoryEngine() *centrifuge.Node

NodeWithMemoryEngine - builder for centrifuge node with memory engine

func NodeWithMemoryEngineNoHandlers

func NodeWithMemoryEngineNoHandlers() *centrifuge.Node

NodeWithMemoryEngineNoHandlers - builder for centrifuge node with memory engine

func OptionalStringChoice added in v5.1.0

func OptionalStringChoice(v *viper.Viper, key string, choices []string) (string, error)

func SecureCompare

func SecureCompare(given, actual []byte) bool

SecureCompare use constant time function to compare the two given array.

func SecureCompareString

func SecureCompareString(given, actual string) bool

SecureCompareString use constant time function to compare the two given string.

func StringToDurationHookFunc

func StringToDurationHookFunc() mapstructure.DecodeHookFunc

StringToDurationHookFunc returns a DecodeHookFunc that converts strings to time.Duration.

func StripPassword

func StripPassword(address string) string

StripPassword from URL address.

Types

type CommonGRPCProxyTestCase

type CommonGRPCProxyTestCase struct {
	Node            *centrifuge.Node
	Client          *centrifuge.Client
	ClientCloseFunc centrifuge.ClientCloseFunc
	Server          *grpc.Server
	Listener        *bufconn.Listener
}

func (*CommonGRPCProxyTestCase) Teardown

func (c *CommonGRPCProxyTestCase) Teardown()

type CommonHTTPProxyTestCase

type CommonHTTPProxyTestCase struct {
	Node            *centrifuge.Node
	Client          *centrifuge.Client
	ClientCloseFunc centrifuge.ClientCloseFunc
	Server          *httptest.Server
	Mux             *http.ServeMux
}

func NewCommonHTTPProxyTestCase

func NewCommonHTTPProxyTestCase(ctx context.Context) *CommonHTTPProxyTestCase

func (*CommonHTTPProxyTestCase) Teardown

func (c *CommonHTTPProxyTestCase) Teardown()

type ConfigGetter

type ConfigGetter interface {
	GetBool(name string) bool
	GetString(name string) string
}

type Duration

type Duration time.Duration

func (Duration) MarshalJSON

func (d Duration) MarshalJSON() ([]byte, error)

func (*Duration) UnmarshalJSON

func (d *Duration) UnmarshalJSON(b []byte) error

type ReadFileFunc added in v5.2.0

type ReadFileFunc func(name string) ([]byte, error)

ReadFileFunc is an abstraction for os.ReadFile but also io/fs.ReadFile wrapped with an io/fs.FS instance.

Note that os.DirFS has slightly different semantics compared to the native filesystem APIs, see https://go.dev/issue/44279

type TLSOptions added in v5.2.0

type TLSOptions struct {
	Cert    string `mapstructure:"tls_cert" json:"tls_cert"`
	Key     string `mapstructure:"tls_key" json:"tls_key"`
	CertPem string `mapstructure:"tls_cert_pem" json:"tls_cert_pem"`
	KeyPem  string `mapstructure:"tls_key_pem" json:"tls_key_pem"`

	RootCA    string `mapstructure:"tls_root_ca" json:"tls_root_ca"`
	RootCAPem string `mapstructure:"tls_root_ca_pem" json:"tls_root_ca_pem"`

	ClientCA    string `mapstructure:"tls_client_ca" json:"tls_client_ca"`
	ClientCAPem string `mapstructure:"tls_client_ca_pem" json:"tls_client_ca_pem"`

	InsecureSkipVerify bool   `mapstructure:"tls_insecure_skip_verify" json:"tls_insecure_skip_verify"`
	ServerName         string `mapstructure:"server_name" json:"server_name"`
}

func (TLSOptions) ToMap added in v5.2.0

func (t TLSOptions) ToMap() (TLSOptionsMap, error)

type TLSOptionsMap added in v5.2.0

type TLSOptionsMap map[string]any

func (TLSOptionsMap) GetBool added in v5.2.0

func (t TLSOptionsMap) GetBool(name string) bool

func (TLSOptionsMap) GetString added in v5.2.0

func (t TLSOptionsMap) GetString(name string) string

type TestClientMock

type TestClientMock struct {
	IDFunc           func() string
	UserIDFunc       func() string
	IsSubscribedFunc func(string) bool
	ContextFunc      func() context.Context
	TransportFunc    func() centrifuge.TransportInfo
	// contains filtered or unexported fields
}

func (*TestClientMock) AcquireStorage

func (m *TestClientMock) AcquireStorage() (map[string]any, func(map[string]any))

func (*TestClientMock) Context

func (m *TestClientMock) Context() context.Context

func (*TestClientMock) Disconnect added in v5.1.0

func (m *TestClientMock) Disconnect(disconnect ...centrifuge.Disconnect)

func (*TestClientMock) ID

func (m *TestClientMock) ID() string

func (*TestClientMock) IsSubscribed

func (m *TestClientMock) IsSubscribed(s string) bool

func (*TestClientMock) Send added in v5.1.0

func (m *TestClientMock) Send(bytes []byte) error

func (*TestClientMock) Transport

func (m *TestClientMock) Transport() centrifuge.TransportInfo

func (*TestClientMock) Unsubscribe added in v5.1.0

func (m *TestClientMock) Unsubscribe(ch string, unsubscribe ...centrifuge.Unsubscribe)

func (*TestClientMock) UserID

func (m *TestClientMock) UserID() string

func (*TestClientMock) WritePublication added in v5.1.0

func (m *TestClientMock) WritePublication(channel string, publication *centrifuge.Publication, sp centrifuge.StreamPosition) error

type TestTransport

type TestTransport struct {
	// contains filtered or unexported fields
}

TestTransport - test transport

func NewTestTransport

func NewTestTransport() *TestTransport

NewTestTransport - builder for TestTransport

func (*TestTransport) Close

func (t *TestTransport) Close(disconnect centrifuge.Disconnect) error

Close - ...

func (*TestTransport) DisabledPushFlags

func (t *TestTransport) DisabledPushFlags() uint64

DisabledPushFlags - ...

func (*TestTransport) Emulation

func (t *TestTransport) Emulation() bool

Emulation ...

func (*TestTransport) Name

func (t *TestTransport) Name() string

Name - ...

func (*TestTransport) PingPongConfig

func (t *TestTransport) PingPongConfig() centrifuge.PingPongConfig

PingPongConfig ...

func (*TestTransport) Protocol

func (t *TestTransport) Protocol() centrifuge.ProtocolType

Protocol - ...

func (*TestTransport) ProtocolVersion

func (t *TestTransport) ProtocolVersion() centrifuge.ProtocolVersion

ProtocolVersion returns transport protocol version.

func (*TestTransport) Unidirectional

func (t *TestTransport) Unidirectional() bool

Unidirectional - ...

func (*TestTransport) Write

func (t *TestTransport) Write(message []byte) error

Write - ...

func (*TestTransport) WriteMany

func (t *TestTransport) WriteMany(messages ...[]byte) error

WriteMany - ...

Jump to

Keyboard shortcuts

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