interfaces

package
v0.2.15 Latest Latest
Warning

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

Go to latest
Published: Dec 30, 2025 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const GlobalDefaultKey = "default"

GlobalDefaultKey is a constant string representing the global default key.

Variables

View Source
var ErrNotImplemented = errors.New("method not implemented")

ErrNotImplemented is returned when a specific decoder method is not implemented by a custom decoder. This signals the runtime to fall back to generic decoding.

Functions

This section is empty.

Types

type AppInfo

type AppInfo interface {
	// ID returns the unique identifier of the application instance.
	ID() string
	// Name returns the name of the application.
	Name() string
	// Version returns the version of the application.
	Version() string
	// Env returns the environment the application is running in (e.g., "dev", "test", "prod").
	Env() string
	// StartTime returns the time when the application started.
	StartTime() time.Time
	// Metadata returns a collection of arbitrary key-value pairs.
	Metadata() map[string]string
}

AppInfo defines the contract for accessing application metadata. It provides a set of read-only methods to retrieve the application's static, immutable identity information. An instance of this interface is considered immutable once created.

type CacheConfigDecoder added in v0.2.13

type CacheConfigDecoder interface {
	DecodeCaches() (*datav1.Caches, error)
}

type Client

type Client interface{}

Client is a tagged interface that represents an instance of a client connection, such as *grpc. ClientConn。 Since clients with different protocols (e.g. gRPC, HTTP) do not have a unified interface, We use an empty interface to provide flexibility, and the caller needs to make type assertions.

type Component added in v0.2.13

type Component interface{}

Component is a generic runtime component.

type Config

type Config interface {
	// Load loads the configuration from its source.
	Load() error

	// Decode provides generic decoding of a configuration key into a target struct.
	// This is the fundamental method that MUST be implemented by any Config instance.
	Decode(key string, value any) error

	// Raw provides an "escape hatch" to the underlying Kratos config.Config instance.
	// Custom implementations can return nil if not applicable.
	Raw() any

	// Close releases any resources held by the configuration.
	// MUST be implemented; can be a no-op if no resources are held.
	Close() error
}

Config is the minimal contract for providing a custom configuration source. Developers wishing to extend the framework with a new config system should implement this interface.

type DataConfigDecoder added in v0.2.11

type DataConfigDecoder interface {
	DecodeData() (*datav1.Data, error)
}

type DatabaseConfigDecoder added in v0.2.13

type DatabaseConfigDecoder interface {
	DecodeDatabases() (*datav1.Databases, error)
}

type DiscoveriesConfigDecoder

type DiscoveriesConfigDecoder interface {
	DecodeDefaultDiscovery() (string, error)
	DecodeDiscoveries() (*discoveryv1.Discoveries, error)
}

DiscoveriesConfigDecoder defines an OPTIONAL interface for providing a "fast path" to decode service discovery configurations. Custom Config implementations can implement this interface to provide an optimized decoding path.

type Encoder

type Encoder func(v any) ([]byte, error)

Encoder defines a function type for encoding a value into a byte slice.

type LoggerConfigDecoder

type LoggerConfigDecoder interface {
	DecodeLogger() (*loggerv1.Logger, error)
}

LoggerConfigDecoder defines an OPTIONAL interface for providing a "fast path" to decode logger configuration. Custom Config implementations can implement this interface to provide an optimized decoding path.

type MiddlewareConfigDecoder

type MiddlewareConfigDecoder interface {
	DecodeMiddlewares() (*middlewarev1.Middlewares, error)
}

MiddlewareConfigDecoder defines an OPTIONAL interface for providing a "fast path" to decode middleware configurations. Custom Config implementations can implement this interface to provide an optimized decoding path.

type ObjectStoreConfigDecoder added in v0.2.13

type ObjectStoreConfigDecoder interface {
	DecodeObjectStores() (*datav1.ObjectStores, error)
}

type Server

type Server interface {
	transport.Server
}

Server is the top-level abstraction for all service types within our framework. It is translated through the inline transport. Server, ensuring that any type that implements our Server interface, At the same time, it also automatically meets the requirements of Kratos App for transport. Server interface.

type ServiceConfigDecoder added in v0.2.7

type ServiceConfigDecoder interface {
	DecodeServers() (*transportv1.Servers, error)
	DecodeClients() (*transportv1.Clients, error)
}

ServiceConfigDecoder defines an OPTIONAL interface for providing a "fast path" to decode service configurations. Custom Config implementations can implement this interface to provide an optimized decoding path.

type StructuredConfig

type StructuredConfig interface {
	DataConfigDecoder
	CacheConfigDecoder
	DatabaseConfigDecoder
	ObjectStoreConfigDecoder
	DiscoveriesConfigDecoder
	LoggerConfigDecoder
	MiddlewareConfigDecoder
	ServiceConfigDecoder

	// DecodedConfig returns the config original decoded value.
	DecodedConfig() any
}

StructuredConfig defines a set of type-safe, recommended methods for decoding configuration. It embeds the generic Config interface to allow for decoding arbitrary values.

Directories

Path Synopsis
Package constant defines the constant keys for structured configuration components.
Package constant defines the constant keys for structured configuration components.
Package storage defines the interfaces for storage services.
Package storage defines the interfaces for storage services.
database
Package database implements the functions, types, and interfaces for the module.
Package database implements the functions, types, and interfaces for the module.

Jump to

Keyboard shortcuts

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