common

package
v0.0.0-...-e7c744b Latest Latest
Warning

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

Go to latest
Published: Jun 21, 2023 License: Apache-2.0 Imports: 1 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ErrorHandler

type ErrorHandler interface {
	Handle(err error)
	HandleContext(ctx context.Context, err error)
}

ErrorHandler handles an error.

type Logger

type Logger interface {
	// Trace logs a trace event.
	Trace(msg string, fields ...map[string]interface{})

	// Debug logs a debug event.
	Debug(msg string, fields ...map[string]interface{})

	// Info logs an info event.
	Info(msg string, fields ...map[string]interface{})

	// Warn logs a warning event.
	Warn(msg string, fields ...map[string]interface{})

	// Error logs an error event.
	Error(msg string, fields ...map[string]interface{})

	// TraceContext logs a trace event with a context.
	TraceContext(ctx context.Context, msg string, fields ...map[string]interface{})

	// DebugContext logs a debug event with a context.
	DebugContext(ctx context.Context, msg string, fields ...map[string]interface{})

	// InfoContext logs an info event with a context.
	InfoContext(ctx context.Context, msg string, fields ...map[string]interface{})

	// WarnContext logs a warning event with a context.
	WarnContext(ctx context.Context, msg string, fields ...map[string]interface{})

	// ErrorContext logs an error event with a context.
	ErrorContext(ctx context.Context, msg string, fields ...map[string]interface{})

	// WithFields annotates a logger with key-value pairs.
	WithFields(fields map[string]interface{}) Logger

	// WithContext annotates a logger with a context.
	WithContext(ctx context.Context) Logger
}

Logger is the fundamental interface for all log operations.

type NoopErrorHandler

type NoopErrorHandler struct{}

NoopErrorHandler is an error handler that discards every error.

func (NoopErrorHandler) Handle

func (NoopErrorHandler) Handle(_ error)

func (NoopErrorHandler) HandleContext

func (NoopErrorHandler) HandleContext(_ context.Context, _ error)

type NoopLogger

type NoopLogger struct{}

NoopLogger is a logger that discards every log event.

func (NoopLogger) Debug

func (NoopLogger) Debug(_ string, _ ...map[string]interface{})

func (NoopLogger) DebugContext

func (NoopLogger) DebugContext(_ context.Context, _ string, _ ...map[string]interface{})

func (NoopLogger) Error

func (NoopLogger) Error(_ string, _ ...map[string]interface{})

func (NoopLogger) ErrorContext

func (NoopLogger) ErrorContext(_ context.Context, _ string, _ ...map[string]interface{})

func (NoopLogger) Info

func (NoopLogger) Info(_ string, _ ...map[string]interface{})

func (NoopLogger) InfoContext

func (NoopLogger) InfoContext(_ context.Context, _ string, _ ...map[string]interface{})

func (NoopLogger) Trace

func (NoopLogger) Trace(_ string, _ ...map[string]interface{})

func (NoopLogger) TraceContext

func (NoopLogger) TraceContext(_ context.Context, _ string, _ ...map[string]interface{})

func (NoopLogger) Warn

func (NoopLogger) Warn(_ string, _ ...map[string]interface{})

func (NoopLogger) WarnContext

func (NoopLogger) WarnContext(_ context.Context, _ string, _ ...map[string]interface{})

func (NoopLogger) WithContext

func (n NoopLogger) WithContext(_ context.Context) Logger

func (NoopLogger) WithFields

func (n NoopLogger) WithFields(_ map[string]interface{}) Logger

type SecretNotFoundError

type SecretNotFoundError struct {
	SecretID string
}

SecretNotFoundError is returned from a SecretStore if a secret cannot be found.

func (SecretNotFoundError) Details

func (e SecretNotFoundError) Details() []interface{}

Details returns details about the error in a generic, loggable format.

func (SecretNotFoundError) Error

func (SecretNotFoundError) Error() string

Error implements the builtin error interface.

func (SecretNotFoundError) NotFound

func (SecretNotFoundError) NotFound() bool

NotFound tells a client that this error is related to a resource being not found. Can be used to translate the error to eg. status code.

func (SecretNotFoundError) ServiceError

func (SecretNotFoundError) ServiceError() bool

ServiceError tells the consumer whether this error is caused by invalid input supplied by the client. Client errors are usually returned to the consumer without retrying the operation.

type SecretStore

type SecretStore interface {
	// GetSecretValues returns the values stored within a secret.
	// If the underlying store uses additional keys for determining the exact secret path
	// (eg. organization ID), it should be retrieved from the context.
	GetSecretValues(ctx context.Context, secretID string) (map[string]string, error)

	GetNameByID(ctx context.Context, secretID string) (string, error)

	GetIDByName(ctx context.Context, secretName string) (string, error)

	Delete(ctx context.Context, secretID string) error
}

SecretStore is a common interface for various parts of the application to read secrets from the platform's secret store.

It is not supposed to expose any implementation specific details. If lower level access is required, use a different interface.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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