bootstrap

package module
v0.0.0-...-de33d0e Latest Latest
Warning

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

Go to latest
Published: Jan 10, 2024 License: MIT Imports: 77 Imported by: 0

README

kratos-bootstrap

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BeDaemon

func BeDaemon(arg string)

BeDaemon converts the current process into a daemon process

func Bootstrap

func Bootstrap(serviceInfo *ServiceInfo) (*conf.Bootstrap, log.Logger, registry.Registrar)

Bootstrap application boot

func CreateGrpcClient

func CreateGrpcClient(ctx context.Context, r registry.Discovery, serviceName string, cfg *conf.Bootstrap, m ...middleware.Middleware) grpc.ClientConnInterface

CreateGrpcClient creates a GRPC client

func CreateGrpcServer

func CreateGrpcServer(cfg *conf.Bootstrap, m ...middleware.Middleware) *kratosGrpc.Server

CreateGrpcServer creates a GRPC server

func CreateRestServer

func CreateRestServer(cfg *conf.Bootstrap, m ...middleware.Middleware) *kratosRest.Server

CreateRestServer creates a REST server

func LoadBootstrapConfig

func LoadBootstrapConfig(configPath string) error

LoadBootstrapConfig loader boot configuration

func LoadRemoteConfigSourceConfigs

func LoadRemoteConfigSourceConfigs(configPath string) (error, *conf.RemoteConfig)

LoadRemoteConfigSourceConfigs loads the local configuration of the remote configuration source

func NewAliyunLogger

func NewAliyunLogger(cfg *conf.Logger) log.Logger

NewAliyunLogger creates a new logger - Aliyun

func NewApolloConfigSource

func NewApolloConfigSource(c *conf.RemoteConfig) config.Source

NewApolloConfigSource creates a remote configuration source - Apollo

func NewConfigProvider

func NewConfigProvider(configPath string) config.Config

NewConfigProvider creates a configuration

func NewConsulConfigSource

func NewConsulConfigSource(c *conf.RemoteConfig) config.Source

NewConsulConfigSource creates a remote configuration source - Consul

func NewConsulRegistry

func NewConsulRegistry(c *conf.Registry) *consulKratos.Registry

NewConsulRegistry creates a registration discovery client - Consul

func NewDiscovery

func NewDiscovery(cfg *conf.Registry) registry.Discovery

NewDiscovery creates a discovery client

func NewEtcdConfigSource

func NewEtcdConfigSource(c *conf.RemoteConfig) config.Source

NewEtcdConfigSource creates a remote configuration source - Etcd

func NewEtcdRegistry

func NewEtcdRegistry(c *conf.Registry) *etcdKratos.Registry

NewEtcdRegistry creates a registration discovery client - Etcd

func NewEurekaRegistry

func NewEurekaRegistry(c *conf.Registry) *eurekaKratos.Registry

NewEurekaRegistry creates a registration discovery client - Eureka

func NewFileConfigSource

func NewFileConfigSource(filePath string) config.Source

NewFileConfigSource creates a local file configuration source

func NewFluentLogger

func NewFluentLogger(cfg *conf.Logger) log.Logger

NewFluentLogger creates a new logger - Fluent

func NewKubernetesConfigSource

func NewKubernetesConfigSource(c *conf.RemoteConfig) config.Source

NewKubernetesConfigSource creates a remote configuration source - Kubernetes

func NewKubernetesRegistry

func NewKubernetesRegistry(_ *conf.Registry) *k8sRegistry.Registry

NewKubernetesRegistry creates a registration discovery client - Kubernetes

func NewLogger

func NewLogger(cfg *conf.Logger) log.Logger

NewLogger creates a new logger

func NewLoggerProvider

func NewLoggerProvider(cfg *conf.Logger, serviceInfo *ServiceInfo) log.Logger

NewLoggerProvider creates a new logger provider

func NewLogrusLogger

func NewLogrusLogger(cfg *conf.Logger) log.Logger

NewLogrusLogger creates a new logger - Logrus

func NewMinIoClient

func NewMinIoClient(conf *conf.OSS) *minio.Client

func NewNacosConfigSource

func NewNacosConfigSource(c *conf.RemoteConfig) config.Source

NewNacosConfigSource creates a remote configuration source - Nacos

func NewNacosRegistry

func NewNacosRegistry(c *conf.Registry) *nacosKratos.Registry

NewNacosRegistry creates a registration discovery client - Nacos

func NewOtlpGrpcExporter

func NewOtlpGrpcExporter(ctx context.Context, endpoint string, insecure bool, options ...otlptracegrpc.Option) (traceSdk.SpanExporter, error)

NewOtlpGrpcExporter creates an OTLP/gRPC exporter, default port: 4317

func NewOtlpHttpExporter

func NewOtlpHttpExporter(ctx context.Context, endpoint string, insecure bool, options ...otlptracehttp.Option) (traceSdk.SpanExporter, error)

NewOtlpHttpExporter creates an OTLP/HTTP exporter, default port: 4318

func NewPolarisConfigSource

func NewPolarisConfigSource(_ *conf.RemoteConfig) config.Source

NewPolarisConfigSource creates a remote configuration source - Polaris

func NewRedisClient

func NewRedisClient(conf *conf.Data) (rdb *redis.Client)

NewRedisClient create go-redis client

func NewRegistry

func NewRegistry(cfg *conf.Registry) registry.Registrar

NewRegistry creates a registration client

func NewRemoteConfigSource

func NewRemoteConfigSource(c *conf.RemoteConfig) config.Source

NewRemoteConfigSource creates a remote configuration source

func NewServicecombRegistry

func NewServicecombRegistry(c *conf.Registry) *servicecombKratos.Registry

NewServicecombRegistry creates a registration discovery client - Servicecomb

func NewStdLogger

func NewStdLogger() log.Logger

NewStdLogger creates a new logger - Kratos built-in, console output

func NewTencentLogger

func NewTencentLogger(cfg *conf.Logger) log.Logger

NewTencentLogger creates a new logger - Tencent

func NewTracerExporter

func NewTracerExporter(exporterName, endpoint string, insecure bool) (traceSdk.SpanExporter, error)

NewTracerExporter creates an exporter, supporting: zipkin, otlp-http, otlp-grpc

func NewTracerProvider

func NewTracerProvider(cfg *conf.Tracer, serviceInfo *ServiceInfo) error

NewTracerProvider creates a link tracker

func NewZapLogger

func NewZapLogger(cfg *conf.Logger) log.Logger

NewZapLogger creates a new logger - Zap

func NewZipkinExporter

func NewZipkinExporter(_ context.Context, endpoint string) (traceSdk.SpanExporter, error)

NewZipkinExporter creates a zipkin exporter, default peer address: http://localhost:9411/api/v2/spans

func NewZooKeeperRegistry

func NewZooKeeperRegistry(c *conf.Registry) *zookeeperKratos.Registry

NewZooKeeperRegistry creates a registration discovery client - ZooKeeper

func RegisterConfig

func RegisterConfig(c interface{})

RegisterConfig registration configuration

Types

type CommandFlags

type CommandFlags struct {
	Conf       string // Boot configuration file path, default is: ../../configs
	Env        string // Development environment: dev, debug...
	ConfigHost string // Remote configuration server address
	ConfigType string // Remote configuration server type
	Daemon     bool   // Whether to convert to daemon process
}

func NewCommandFlags

func NewCommandFlags() *CommandFlags

func (*CommandFlags) Init

func (f *CommandFlags) Init()

type ConfigType

type ConfigType string
const (
	ConfigTypeLocalFile  ConfigType = "file"
	ConfigTypeNacos      ConfigType = "nacos"
	ConfigTypeConsul     ConfigType = "consul"
	ConfigTypeEtcd       ConfigType = "etcd"
	ConfigTypeApollo     ConfigType = "apollo"
	ConfigTypeKubernetes ConfigType = "kubernetes"
	ConfigTypePolaris    ConfigType = "polaris"
)

type LoggerType

type LoggerType string
const (
	LoggerTypeStd     LoggerType = "std"
	LoggerTypeFluent  LoggerType = "fluent"
	LoggerTypeLogrus  LoggerType = "logrus"
	LoggerTypeZap     LoggerType = "zap"
	LoggerTypeAliyun  LoggerType = "aliyun"
	LoggerTypeTencent LoggerType = "tencent"
)

type RegistryType

type RegistryType string
const (
	RegistryTypeConsul    RegistryType = "consul"
	LoggerTypeEtcd        RegistryType = "etcd"
	LoggerTypeZooKeeper   RegistryType = "zookeeper"
	LoggerTypeNacos       RegistryType = "nacos"
	LoggerTypeKubernetes  RegistryType = "kubernetes"
	LoggerTypeEureka      RegistryType = "eureka"
	LoggerTypePolaris     RegistryType = "polaris"
	LoggerTypeServicecomb RegistryType = "servicecomb"
)

type ServiceInfo

type ServiceInfo struct {
	Name     string
	Version  string
	Id       string
	Metadata map[string]string
}

func NewServiceInfo

func NewServiceInfo(name, version, id string) *ServiceInfo

func (*ServiceInfo) GetInstanceId

func (s *ServiceInfo) GetInstanceId() string

func (*ServiceInfo) SetMataData

func (s *ServiceInfo) SetMataData(k, v string)

Directories

Path Synopsis
gen

Jump to

Keyboard shortcuts

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