bootstrap

package module
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Nov 13, 2023 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 将当前进程转为守护进程

func Bootstrap

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

Bootstrap 应用引导启动

func CreateGrpcClient

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

CreateGrpcClient 创建GRPC客户端

func CreateGrpcServer

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

CreateGrpcServer 创建GRPC服务端

func CreateRestServer

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

CreateRestServer 创建REST服务端

func LoadBootstrapConfig

func LoadBootstrapConfig(configPath string) error

LoadBootstrapConfig 加载程序引导配置

func LoadRemoteConfigSourceConfigs

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

LoadRemoteConfigSourceConfigs 加载远程配置源的本地配置

func NewAliyunLogger

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

NewAliyunLogger 创建一个新的日志记录器 - Aliyun

func NewApolloConfigSource

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

NewApolloConfigSource 创建一个远程配置源 - Apollo

func NewConfigProvider

func NewConfigProvider(configPath string) config.Config

NewConfigProvider 创建一个配置

func NewConsulConfigSource

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

NewConsulConfigSource 创建一个远程配置源 - Consul

func NewConsulRegistry

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

NewConsulRegistry 创建一个注册发现客户端 - Consul

func NewDiscovery

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

NewDiscovery 创建一个发现客户端

func NewEtcdConfigSource

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

NewEtcdConfigSource 创建一个远程配置源 - Etcd

func NewEtcdRegistry

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

NewEtcdRegistry 创建一个注册发现客户端 - Etcd

func NewEurekaRegistry

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

NewEurekaRegistry 创建一个注册发现客户端 - Eureka

func NewFileConfigSource

func NewFileConfigSource(filePath string) config.Source

NewFileConfigSource 创建一个本地文件配置源

func NewFluentLogger

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

NewFluentLogger 创建一个新的日志记录器 - Fluent

func NewKubernetesConfigSource

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

NewKubernetesConfigSource 创建一个远程配置源 - Kubernetes

func NewKubernetesRegistry

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

NewKubernetesRegistry 创建一个注册发现客户端 - Kubernetes

func NewLogger

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

NewLogger 创建一个新的日志记录器

func NewLoggerProvider

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

NewLoggerProvider 创建一个新的日志记录器提供者

func NewLogrusLogger

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

NewLogrusLogger 创建一个新的日志记录器 - Logrus

func NewMinIoClient

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

func NewNacosConfigSource

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

NewNacosConfigSource 创建一个远程配置源 - Nacos

func NewNacosRegistry

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

NewNacosRegistry 创建一个注册发现客户端 - Nacos

func NewOtlpGrpcExporter

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

NewOtlpGrpcExporter 创建OTLP/gRPC导出器,默认端口:4317

func NewOtlpHttpExporter

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

NewOtlpHttpExporter 创建OTLP/HTTP导出器,默认端口:4318

func NewPolarisConfigSource

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

NewPolarisConfigSource 创建一个远程配置源 - Polaris

func NewRedisClient

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

NewRedisClient 创建Redis客户端

func NewRegistry

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

NewRegistry 创建一个注册客户端

func NewRemoteConfigSource

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

NewRemoteConfigSource 创建一个远程配置源

func NewServicecombRegistry

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

NewServicecombRegistry 创建一个注册发现客户端 - Servicecomb

func NewStdLogger

func NewStdLogger() log.Logger

NewStdLogger 创建一个新的日志记录器 - Kratos内置,控制台输出

func NewTencentLogger

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

NewTencentLogger 创建一个新的日志记录器 - Tencent

func NewTracerExporter

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

NewTracerExporter 创建一个导出器,支持:zipkin、otlp-http、otlp-grpc

func NewTracerProvider

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

NewTracerProvider 创建一个链路追踪器

func NewZapLogger

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

NewZapLogger 创建一个新的日志记录器 - Zap

func NewZipkinExporter

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

NewZipkinExporter 创建一个zipkin导出器,默认对端地址:http://localhost:9411/api/v2/spans

func NewZooKeeperRegistry

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

NewZooKeeperRegistry 创建一个注册发现客户端 - ZooKeeper

func RegisterConfig

func RegisterConfig(c interface{})

RegisterConfig 注册配置

Types

type CommandFlags

type CommandFlags struct {
	Conf       string // 引导配置文件路径,默认为:../../configs
	Env        string // 开发环境:dev、debug……
	ConfigHost string // 远程配置服务端地址
	ConfigType string // 远程配置服务端类型
	Daemon     bool   // 是否转为守护进程
}

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