conf

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Jun 7, 2023 License: MIT Imports: 2 Imported by: 0

Documentation

Overview

Package conf 配置文件

  • @Author: windealli windealli@tencent.com
  • @Date: 2023-03-12 12:34:36
  • @LastEditors: windealli windealli@tencent.com
  • @LastEditTime: 2023-03-12 13:00:53
  • @FilePath: /kratos-layout/internal/conf/base.go
  • @Description: Bootstrap 对象用于存放服务相关的所有配置

Package conf ...

  • @Author: windealli windealli@tencent.com
  • @Date: 2023-03-13 15:46:21
  • @LastEditors: windealli windealli@tencent.com
  • @LastEditTime: 2023-03-14 20:47:41
  • @FilePath: /kratos-layout/internal/conf/ops_conf.go
  • @Description: 本文件一般只放运维配置相关的代码,请不要把业务配置的代码放在此处

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Bootstrap

type Bootstrap struct {
	Ops    *Ops            // 运维组件相关的配置,比如云上的DB、Redis、Kafka、COS相关信息
	Server *Server         `json:"server"` // 服务启动的基本信息,如http、grpc相关的配置
	BC     *BusinessConfig // 业务配置,用于存放本服务相关的业务配置,如某些开关,域名等
}

Bootstrap 全量配置

type BusinessConfig

type BusinessConfig struct {
	LoginConf LoginConf `yaml:"login_conf"` // 业务登录态相关的配置
}

BusinessConfig 业务配置

type Cos

type Cos struct {
	SecretID  string
	SecretKey string
}

Cos 云上Cos相关配置

type GrpcServer

type GrpcServer struct {
	Network string // 网络类型,如tcp
	Addr    string // grpc服务地址,如0.0.0.0:8000
	Timeout int    // grpc服务超时时间,
}

GrpcServer server 配置

type HttpServer

type HttpServer struct {
	Network string // 网络类型,如tcp
	Addr    string // http服务地址,如0.0.0.0:9000
	Timeout int    // http服务超时时间,
}

HttpServer http server配置

type Log

type Log struct {
	Path          string // 日志存储路径
	Compress      bool   // 是否压缩
	ConsoleStdout bool   // 是否输出到控制台
	FileStdout    bool   // 是否输出到文件
	Level         string // 日志级别
	LocalTime     bool   // 是否使用本地时间
	MaxAge        int    // 日志保留天数
	MaxSize       int    // 日志文件最大尺寸,单位MB
	MaxBackups    int    // 日志文件最大备份数
}

Log 日志配置

func (*Log) EnableCompress

func (log *Log) EnableCompress() bool

EnableCompress 是否压缩日志

func (*Log) EnableConsuleStdout

func (log *Log) EnableConsuleStdout() bool

EnableConsuleStdout 是否输出控制台日志

func (*Log) EnableFileStdout

func (log *Log) EnableFileStdout() bool

EnableFileStdout 是否输入文件日志

func (*Log) GetLogLevel

func (log *Log) GetLogLevel() string

GetLogLevel 日志级别

func (*Log) GetLogPath

func (log *Log) GetLogPath() string

GetLogPath 日志存储路径

func (*Log) GetMaxAge

func (log *Log) GetMaxAge() int

GetMaxAge 日志保留天数

func (*Log) GetMaxBackups

func (log *Log) GetMaxBackups() int

GetMaxBackups 日志文件最大备份数

func (*Log) GetMaxSize

func (log *Log) GetMaxSize() int

GetMaxSize 日志文件最大尺寸, 单位MB

func (*Log) UseLocalTime

func (log *Log) UseLocalTime() bool

UseLocalTime 是否使用本地时间

type LoginConf added in v0.1.1

type LoginConf struct {
	// JWT-Token特定的配置, 使用JWT-TOKEN的登录方式,需要配置
	JWTSecret string `yaml:"jwt_secret"` // JWT签名密钥, 如果使用JWT-Token,必须设置

	// 业务登录态相关配置,使用Cookie和JWT-Token,都必须设置
	Timeout    int64  `yaml:"timeout"` // 登录态超时时间, 默认2小时
	CookieName string `yaml:"cookie_name"`
}

LoginConf 业务登录态相关的配置

type MySQL

type MySQL struct {
	Host     string
	Port     int
	Username string
	Password string
	DB       string
}

MySQL 数据库配置

type Ops

type Ops struct {
	Mysql   MySQL
	MysqlRO MySQL
	Redis   Redis
	Tracing Tracing
	Log     Log
}

Ops 运维配置

func (*Ops) GetLog

func (ops *Ops) GetLog() *Log

GetLog 获取日志相关配置

func (*Ops) GetTracing

func (ops *Ops) GetTracing() (*Tracing, error)

GetTracing 获取链路追踪的配置

type Redis

type Redis struct {
	Host     string
	Port     int
	DB       int
	Password string
}

Redis 配置

type Server

type Server struct {
	Name    string
	Version string
	Grpc    *GrpcServer `json:"grpc"`
	Http    *HttpServer `json:"http"`
}

Server 服务配置

type Tracing

type Tracing struct {
	Endpoint string // 链路追踪服务地址
	Token    string // 链路追踪服务token
}

Tracing 链路追踪配置

func (*Tracing) GetEndpoint

func (tr *Tracing) GetEndpoint() string

GetEndpoint 获取Endpoing

func (*Tracing) GetToken

func (tr *Tracing) GetToken() string

GetToken 获取Token

Jump to

Keyboard shortcuts

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