Documentation
¶
Index ¶
- func ProvideDefaultRegistrar(rt Runtime) registry.Registrar
- func ProvideLogger(rt Runtime) log.Logger
- func WithAppInfo(info *AppInfo) bootstrap.Option
- type AppInfo
- func (a AppInfo) GetEnv() string
- func (a AppInfo) GetID() string
- func (a AppInfo) GetName() string
- func (a AppInfo) GetStartTime() time.Time
- func (a AppInfo) GetUptime() time.Duration
- func (a AppInfo) GetVersion() string
- func (a AppInfo) IsValid() bool
- func (a AppInfo) Options() []kratos.Option
- func (a AppInfo) String() string
- func (a AppInfo) WithMetadata(key, value string) AppInfo
- type Runtime
- func (r *Runtime) AppInfo() *interfaces.AppInfo
- func (r *Runtime) Cleanup()
- func (r *Runtime) Component(name string) (interface{}, bool)
- func (r *Runtime) Config() interfaces.Config
- func (r *Runtime) Container() interfaces.Container
- func (r *Runtime) DefaultRegistrar() registry.Registrar
- func (r *Runtime) Discovery(name string) (registry.Discovery, bool)
- func (r *Runtime) Logger() log.Logger
- func (r *Runtime) NewApp(servers []transport.Server, options ...kratos.Option) *kratos.App
- func (r *Runtime) Registrar(name string) (registry.Registrar, bool)
- func (r *Runtime) StructuredConfig() interfaces.StructuredConfig
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ProvideDefaultRegistrar ¶ added in v0.2.6
ProvideDefaultRegistrar is a Wire provider function that extracts the default registrar from the Runtime interface. It is intended to be used by the application's own Wire injector.
func ProvideLogger ¶ added in v0.2.6
ProvideLogger is a Wire provider function that extracts the logger from the Runtime interface. It is intended to be used by the application's own Wire injector.
func WithAppInfo ¶ added in v0.2.7
WithAppInfo returns an Option that sets the application information.
Types ¶
type AppInfo ¶ added in v0.2.6
type AppInfo interfaces.AppInfo
AppInfo represents the application's static, immutable identity information. It includes essential metadata such as the application's name, version, environment, and instance ID. This information is determined at startup and remains constant throughout the application's lifecycle.
func NewAppInfo ¶ added in v0.2.6
NewAppInfo creates a new AppInfo instance with default values for ID, StartTime, and Metadata. It requires the application's name, version, and environment.
func (AppInfo) GetEnv ¶ added in v0.2.6
GetEnv returns the environment the application is running in.
func (AppInfo) GetID ¶ added in v0.2.6
GetID returns the unique identifier of the application instance.
func (AppInfo) GetStartTime ¶ added in v0.2.6
GetStartTime returns the time the application was started.
func (AppInfo) GetUptime ¶ added in v0.2.6
GetUptime returns the duration since the application was started.
func (AppInfo) GetVersion ¶ added in v0.2.6
GetVersion returns the version of the application.
func (AppInfo) IsValid ¶ added in v0.2.6
IsValid checks if the AppInfo instance contains essential, non-empty identification fields.
func (AppInfo) Options ¶ added in v0.2.6
Options returns a slice of kratos.Option with the application's identity fields, suitable for passing to kratos.New().
func (AppInfo) String ¶ added in v0.2.6
String implements the fmt.Stringer interface for easy logging and identification. It returns a string in the format "name-version".
func (AppInfo) WithMetadata ¶ added in v0.2.6
WithMetadata returns a new AppInfo with the provided key-value pair added to the metadata. This method supports fluent chaining, e.g., appInfo.WithMetadata(...).WithMetadata(...)
type Runtime ¶ added in v0.1.15
type Runtime struct {
// contains filtered or unexported fields
}
Runtime defines the application's runtime environment, providing convenient access to core components. It encapsulates an interfaces.Container and is the primary object that applications will interact with.
func New ¶
New is the core constructor for a Runtime instance. It takes a fully initialized bootstrap result, which is guaranteed to be non-nil.
func NewFromBootstrap ¶ added in v0.2.6
NewFromBootstrap is a convenience constructor that simplifies application startup. It encapsulates the entire process of calling bootstrap.New and then runtime.New. It accepts bootstrap.Option parameters directly, allowing the user to configure the bootstrap process.
func (*Runtime) AppInfo ¶ added in v0.2.6
func (r *Runtime) AppInfo() *interfaces.AppInfo
AppInfo returns the application's configured information (ID, name, version, metadata).
func (*Runtime) Cleanup ¶ added in v0.2.7
func (r *Runtime) Cleanup()
Cleanup executes the cleanup function for all resources acquired during bootstrap. This should be called via defer right after the Runtime is created.
func (*Runtime) Component ¶ added in v0.2.6
Component retrieves a generic, user-defined component by its registered name.
func (*Runtime) Config ¶ added in v0.1.15
func (r *Runtime) Config() interfaces.Config
Config returns the configuration decoder, allowing access to raw configuration values.
func (*Runtime) Container ¶ added in v0.2.7
func (r *Runtime) Container() interfaces.Container
Container returns the underlying dependency injection container. This method is primarily for advanced use cases where direct access to the container is necessary. For most common operations, prefer using the specific accessor methods provided by the Runtime (e.g., Logger(), Config(), Component()).
func (*Runtime) DefaultRegistrar ¶ added in v0.2.6
DefaultRegistrar returns the default service registrar, used for service self-registration. It may be nil if no default registry is configured.
func (*Runtime) Discovery ¶ added in v0.2.6
Discovery returns a service discovery component by its configured name.
func (*Runtime) NewApp ¶ added in v0.2.6
NewApp creates a new Kratos application instance. It wires together the runtime's configured components (like the default registrar) with the provided transport servers. It now accepts additional Kratos options for more flexible configuration.
func (*Runtime) Registrar ¶ added in v0.2.6
Registrar returns a service registrar component by its configured name.
func (*Runtime) StructuredConfig ¶ added in v0.2.7
func (r *Runtime) StructuredConfig() interfaces.StructuredConfig
StructuredConfig returns the structured configuration decoder, which provides path-based access to configuration values. This is typically used for initializing components like servers and clients that require specific configuration blocks.
Directories
¶
| Path | Synopsis |
|---|---|
|
api
|
|
|
Package bootstrap implements the functions, types, and interfaces for the module.
|
Package bootstrap implements the functions, types, and interfaces for the module. |
|
Package config contains generated code by adptool.
|
Package config contains generated code by adptool. |
|
envsource
Package envsource is a configuration source that loads environment variables.
|
Package envsource is a configuration source that loads environment variables. |
|
file
Package file implements the functions, types, and interfaces for the module.
|
Package file implements the functions, types, and interfaces for the module. |
|
internal/reflection
Package reflection implements the functions, types, and interfaces for the module.
|
Package reflection implements the functions, types, and interfaces for the module. |
|
Package context contains generated code by adptool.
|
Package context contains generated code by adptool. |
|
Package errors provides enhanced error handling with module support, error codes, and metadata.
|
Package errors provides enhanced error handling with module support, error codes, and metadata. |
|
examples
|
|
|
configs/bootstrap_sample
command
|
|
|
configs/load_with_custom_parser
command
|
|
|
configs/load_with_interface
command
|
|
|
configs/load_with_runtime
command
|
|
|
storage
command
|
|
|
extension
|
|
|
customize
Package customize provides helper functions for working with flexible configuration structures in Protobuf, such as google.protobuf.Struct and google.protobuf.Any.
|
Package customize provides helper functions for working with flexible configuration structures in Protobuf, such as google.protobuf.Struct and google.protobuf.Any. |
|
database
Package database implements the functions, types, and interfaces for the module.
|
Package database implements the functions, types, and interfaces for the module. |
|
pagination
Package pagination implements the functions, types, and interfaces for the module.
|
Package pagination implements the functions, types, and interfaces for the module. |
|
security
Package security implements the functions, types, and interfaces for the module.
|
Package security implements the functions, types, and interfaces for the module. |
|
security/token
Package token provides token caching functionality for security module
|
Package token provides token caching functionality for security module |
|
storage
Package storage implements the functions, types, and interfaces for the module.
|
Package storage implements the functions, types, and interfaces for the module. |
|
storage/components/blob
Package blob implements the functions, types, and interfaces for the module.
|
Package blob implements the functions, types, and interfaces for the module. |
|
storage/components/layout
Package layout provides a generic interface for storage layouts.
|
Package layout provides a generic interface for storage layouts. |
|
storage/components/meta
Package meta implements the functions, types, and interfaces for the module.
|
Package meta implements the functions, types, and interfaces for the module. |
|
Package log implements the functions, types, and interfaces for the module.
|
Package log implements the functions, types, and interfaces for the module. |
|
Package mail implements the functions, types, and interfaces for the module.
|
Package mail implements the functions, types, and interfaces for the module. |
|
Package middleware implements the functions, types, and interfaces for the module.
|
Package middleware implements the functions, types, and interfaces for the module. |
|
cors
Package cors implements CORS middleware for the framework.
|
Package cors implements CORS middleware for the framework. |
|
validate
Package validate implements the functions, types, and interfaces for the module.
|
Package validate implements the functions, types, and interfaces for the module. |
|
Package optionutil provides utility functions for working with options.Context.
|
Package optionutil provides utility functions for working with options.Context. |
|
Package registry contains generated code by adptool.
|
Package registry contains generated code by adptool. |
|
Package service contains generated code by adptool.
|
Package service contains generated code by adptool. |
|
selector
Package selector contains generated code by adptool.
|
Package selector contains generated code by adptool. |
|
tls
Package tls implements the functions, types, and interfaces for the module.
|
Package tls implements the functions, types, and interfaces for the module. |
|
Package storage implements the functions, types, and interfaces for the module.
|
Package storage implements the functions, types, and interfaces for the module. |
|
filestore/meta
Package meta implements the functions, types, and interfaces for the module.
|
Package meta implements the functions, types, and interfaces for the module. |
|
filestore/meta/v1
Package metav1 implements the functions, types, and interfaces for the module.
|
Package metav1 implements the functions, types, and interfaces for the module. |
|
filestore/meta/v2
Package metav2 implements the functions, types, and interfaces for the module.
|
Package metav2 implements the functions, types, and interfaces for the module. |
|
test
|
|