zero

package
v0.0.0-...-06f9d85 Latest Latest
Warning

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

Go to latest
Published: May 31, 2024 License: MIT Imports: 8 Imported by: 0

Documentation

Overview

配置 直接从环境变量读取 `json:",env=SERVICE_NAME"` 或者配置yaml文件 ${SERVICE_NAME}

https://go-zero.dev/ https://github.com/zeromicro/zero-examples

go zero 目前支持k8s版本 k8s.io/api v0.26.3 k8s.io/apimachinery v0.27.0-alpha.3 k8s.io/client-go v0.26.3

Index

Constants

View Source
const (
	DevMode  = "dev"  // 开发
	TestMode = "test" // 测试
	RtMode   = "rt"   // 回归测试
	PreMode  = "pre"  // 预生产
	ProMode  = "pro"  // 生产
)

运行环境

Variables

View Source
var (
	// 加载配置,失败则返回错误
	Load = conf.Load
)

Functions

func Dial

func Dial(target string) (*grpc.ClientConn, error)

Dial creates a client connection to the given target. 目标 localhost:9090 连接用完调用grpc.ClientConn.Close()关闭

func MustLoad

func MustLoad(path string, v any)

MustLoad 加载配置,失败则退出程序

Types

type Config

type Config struct {
	zrpc.RpcServerConf
	MySQL struct {
		Host     string
		Port     int
		User     string
		Pass     string
		Database string
	}
	// zrpc.RpcServerConf.Redis字段必须设置Key
	// 所以另外定义字段,且字段名不能和Redis重名
	RedisC struct {
		Addr string
		Pass string
		DB   int
	}
	Bool bool
}

Config rpc服务配置

type EtcdConf

type EtcdConf = discov.EtcdConf

EtcdConf is the config item with the given key on etcd. Hosts etcd host array 127.0.0.1:2379 Key rpc registration key

type Logger

type Logger = logx.Logger

Logger 日志记录 Error() fmt.Sprint Errorf() fmt.Sprintf Errorv() json编码后记录 Errorw() 记录键值对

type RedisConf

type RedisConf = redis.RedisConf

A RedisConf is a redis config. Host redis地址 localhost:6379 Pass redis密码

type RpcClientConf

type RpcClientConf = zrpc.RpcClientConf

RpcClientConf is a rpc client config. Etcd etcd related configuration Target rpc服务地址 localhost:9090

type RpcServerConf

type RpcServerConf = zrpc.RpcServerConf

RpcServerConf is a rpc server config. ListenOn 监听地址 Etcd etcd related configuration Timeout 接口最大响应时间

type ServiceConf

type ServiceConf = service.ServiceConf

ServiceConf is a service config. Name service name Mode 运行环境,默认为生产环境

Jump to

Keyboard shortcuts

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