Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Database ¶
type Database struct { Driver string `yaml:"driver" json:"driver"` Mysql DbAddr `yaml:"mysql" json:"mysql"` Redis DbAddr `yaml:"redis" json:"redis"` Mongodb DbAddr `yaml:"mongodb" json:"mongodb"` Postgresql DbAddr `yaml:"postgresql" json:"postgresql"` Sqlite DbAddr `yaml:"sqlite" json:"sqlite"` Oracle DbAddr `yaml:"oracle" json:"oracle"` SQLServer DbAddr `yaml:"sqlserver" json:"sqlserver"` Cassandra DbAddr `yaml:"cassandra" json:"cassandra"` InfluxDB DbAddr `yaml:"influxdb" json:"influxdb"` Elasticsearch DbAddr `yaml:"elasticsearch" json:"elasticsearch"` Clickhouse DbAddr `yaml:"clickhouse" json:"clickhouse"` Cockroachdb DbAddr `yaml:"cockroachdb" json:"cockroachdb"` Tidb DbAddr `yaml:"tidb" json:"tidb"` }
type GenericConfig ¶
type GenericConfig struct { App App `yaml:"app" json:"app"` Grpc Grpc `yaml:"grpc" json:"grpc"` GrpcClient []GrpcClient `yaml:"grpcClient" json:"grpcClient"` HTTP HTTP `yaml:"http" json:"http"` HTTPClient []HTTPClient `yaml:"httpClient" json:"httpClient"` // database config, match 2 configuration modes, one is separate configuration, the other is unified configuration Database Database `yaml:"database" json:"database"` Mysql map[string]interface{} `yaml:"mysql" json:"mysql"` Redis map[string]interface{} `yaml:"redis" json:"redis"` Mongodb map[string]interface{} `yaml:"mongodb" json:"mongodb"` Postgresql map[string]interface{} `yaml:"postgresql" json:"postgresql"` Sqlite map[string]interface{} `yaml:"sqlite" json:"sqlite"` Oracle map[string]interface{} `yaml:"oracle" json:"oracle"` SQLServer map[string]interface{} `yaml:"sqlserver" json:"sqlserver"` Cassandra map[string]interface{} `yaml:"cassandra" json:"cassandra"` InfluxDB map[string]interface{} `yaml:"influxdb" json:"influxdb"` Elasticsearch map[string]interface{} `yaml:"elasticsearch" json:"elasticsearch"` Clickhouse map[string]interface{} `yaml:"clickhouse" json:"clickhouse"` Cockroachdb map[string]interface{} `yaml:"cockroachdb" json:"cockroachdb"` Tidb map[string]interface{} `yaml:"tidb" json:"tidb"` // mq config, match 2 configuration modes, one is separate configuration, the other is unified configuration MqClient []MqClient `yaml:"mqClient" json:"mqClient"` Rabbitmq map[string]interface{} `yaml:"rabbitmq" json:"rabbitmq"` Kafka map[string]interface{} `yaml:"kafka" json:"kafka"` Activemq map[string]interface{} `yaml:"activemq" json:"activemq"` Rocketmq map[string]interface{} `yaml:"rocketmq" json:"rocketmq"` Nats map[string]interface{} `yaml:"nats" json:"nats"` Nsq map[string]interface{} `yaml:"nsq" json:"nsq"` Asynq map[string]interface{} `yaml:"asynq" json:"asynq"` Pulsar map[string]interface{} `yaml:"pulsar" json:"pulsar"` Zeromq map[string]interface{} `yaml:"zeromq" json:"zeromq"` // contains filtered or unexported fields }
func ParseYaml ¶
func ParseYaml(configFile string, isAll bool) (*GenericConfig, error)
ParseYaml parses the YAML file and returns a GenericConfig, yaml file content example:
app:
name: "eshop-gw"
# http server settings example http:
port: 8080 timeout: 0
# http client settings example httpClient:
- name: "flashSale" baseURL: "http://127.0.0.1:8080"
- name: "product" baseURL: "http://127.0.0.1:8081"
# grpc server settings example grpc:
port: 8282 httpPort: 8283
# grpc client settings example grpcClient:
- name: "user" host: "127.0.0.1" port: 18282
- name: "order" host: "127.0.0.1" port: 28282
# db settings example database:
mysql: dsn: "root:123456@(192.168.3.37:3306)/eshop_order?parseTime=true&loc=Local&charset=utf8,utf8mb4" mongodb: dsn: "root:123456@192.168.3.37:27017/account?connectTimeoutMS=15000"
# or redis:
dsn: "default:123456@192.168.3.37:6379/0"
postgresql:
dsn: "root:123456@192.168.3.37:5432/account?sslmode=disable"
# mq settings example kafka:
mode: "producer,consumer" brokers: ["192.168.3.37:9092"]
rabbitmq:
mode: "consumer" host: "192.168.3.37" port: 5672
func (*GenericConfig) GetDependencies ¶
func (c *GenericConfig) GetDependencies(serviceName string) (map[string][]string, []Service)
GetDependencies returns the dependencies of the service.
func (*GenericConfig) GetServiceName ¶
func (c *GenericConfig) GetServiceName() string
GetServiceName returns the name of the service.
func (*GenericConfig) GetServiceType ¶
func (c *GenericConfig) GetServiceType() string
GetServiceType returns the type of the service.
type GrpcClient ¶
type HTTPClient ¶
type MqClient ¶
type MqClient struct { Name string `yaml:"name" json:"name"` // rabbitmq, kafka, activemq, rocketmq, nats, nsq, redis, asynq, pulsar, zeromq, etc. Mode string `yaml:"mode" json:"mode"` // producer, consumer. Rabbitmq map[string]interface{} `yaml:"rabbitmq" json:"rabbitmq"` Kafka map[string]interface{} `yaml:"kafka" json:"kafka"` Activemq map[string]interface{} `yaml:"activemq" json:"activemq"` Rocketmq map[string]interface{} `yaml:"rocketmq" json:"rocketmq"` Nats map[string]interface{} `yaml:"nats" json:"nats"` Nsq map[string]interface{} `yaml:"nsq" json:"nsq"` Redis map[string]interface{} `yaml:"redis" json:"redis"` Asynq map[string]interface{} `yaml:"asynq" json:"asynq"` Pulsar map[string]interface{} `yaml:"pulsar" json:"pulsar"` Zeromq map[string]interface{} `yaml:"zeromq" json:"zeromq"` }
type ProjectConfig ¶
type ProjectConfig struct {
Services []Service `yaml:"services"`
}
ProjectConfig represents the configuration of the project.
func NewProjectConfig ¶
func NewProjectConfig() *ProjectConfig
NewProjectConfig creates a new ProjectConfig.
func (*ProjectConfig) AddService ¶
func (c *ProjectConfig) AddService(config *GenericConfig)
AddService adds a new service to the project configuration.