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 6, 2023 License: MIT Imports: 65 Imported by: 0

README

go-bootstrap

A useful helper for go-micro project

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)

func CreateGrpcClient

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

CreateGrpcClient creates gRPC client

func CreateGrpcServer

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

CreateGrpcServer creates gRPC server

func CreateHTTPServer

func CreateHTTPServer(cfg *conf.Bootstrap, m ...middleware.Middleware) *httpGoMicro.Server

CreateHTTPServer 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 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) *consulGoMicro.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) *etcdGoMicro.Registry

NewEtcdRegistry creates a registration discovery client - Etcd

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 NewJaegerExporter

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

NewJaegerExporter creates a jaeger exporter. The default peer address is: http://localhost:14268/api/traces

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 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 NewRedisClient

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

NewRedisClient creates 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 创建一个远程配置源

func NewStdLogger

func NewStdLogger() log.Logger

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

func NewTracerExporter

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

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

func NewTracerProvider

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

NewTracerProvider creates a link tracer

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) *zookeeperGoMicro.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: ../../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"
	ConfigTypeConsul     ConfigType = "consul"
	ConfigTypeEtcd       ConfigType = "etcd"
	ConfigTypeKubernetes ConfigType = "kubernetes"
)

type LoggerType

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

type RegistryType

type RegistryType string
const (
	RegistryTypeConsul   RegistryType = "consul"
	LoggerTypeEtcd       RegistryType = "etcd"
	LoggerTypeZooKeeper  RegistryType = "zookeeper"
	LoggerTypeKubernetes RegistryType = "kubernetes"
)

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