configx

package
v0.0.0-...-fefde71 Latest Latest
Warning

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

Go to latest
Published: Nov 10, 2024 License: GPL-3.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Application

type Application struct {
	ID   string `json:"id" yaml:"id"`
	Name string `json:"name" yaml:"name"`

	Log  logging.Options `json:"log" yaml:"log"`
	HTTP HTTP            `json:"http" yaml:"http"`
	GRPC GRPC            `json:"grpc" yaml:"grpc"`

	Auth0 struct {
		Domain       string   `json:"domain" yaml:"domain"`
		ClientID     string   `json:"client_id" yaml:"clientID"`
		ClientSecret string   `json:"client_secret" yaml:"clientSecret"`
		CallbackURL  string   `json:"callback_url" yaml:"callbackURL"`
		Audiences    []string `json:"audiences" yaml:"audiences"`
	} `json:"auth0" yaml:"auth0"`

	Casbin struct {
		// Enabled is the casbin enabled
		Enabled bool `json:"enabled" yaml:"enabled"`

		// ModelPath is the casbin model path
		ModelPath string `json:"model_path" yaml:"modelPath"`

		// PolicyDriver is the casbin policy driver
		PolicyDriver string `json:"policy_driver" yaml:"policyDriver"`
	} `json:"casbin" yaml:"casbin"`

	Storage struct {
		Mysql struct {
			DSN string `json:"dsn" yaml:"dsn"`
		} `json:"mysql" yaml:"mysql"`

		Postgresql struct {
			DSN string `json:"dsn" yaml:"dsn"`
		} `json:"postgresql" yaml:"postgresql"`

		Mongodb struct {
			DSN string `json:"dsn" yaml:"dsn"`
		} `json:"mongodb" yaml:"mongodb"`

		Redis struct {
			Addr string `json:"addr" yaml:"addr"`
		} `json:"redis" yaml:"redis"`
	} `json:"storage" yaml:"storage"`

	Kafka struct {
		Username string   `json:"username" yaml:"username"`
		Password string   `json:"password" yaml:"password"`
		Brokers  []string `json:"brokers" yaml:"brokers"`
	} `json:"kafka" yaml:"kafka"`

	OTel struct {
		Target string `json:"target" yaml:"target"`
	} `json:"otel" yaml:"otel"`
}

Application defines the application struct.

func NewApplication

func NewApplication(v *viper.Viper, name string) (*Application, error)

NewApplication is used to create a new application.

func (*Application) GetID

func (x *Application) GetID() string

GetID is used to get the application id.

func (*Application) String

func (x *Application) String() string

type Configuration

type Configuration struct {
	RestaurantRestful Application `json:"restaurant_restful" yaml:"restaurantRestful"`
	OrderRestful      Application `json:"order_restful" yaml:"orderRestful"`
	OrderHandler      Application `json:"order_handler" yaml:"orderHandler"`
	UserRestful       Application `json:"user_restful" yaml:"userRestful"`
	LogisticsRestful  Application `json:"logistics_restful" yaml:"logisticsRestful"`
	NotifyRestful     Application `json:"notify_restful" yaml:"notifyRestful"`

	Log      logging.Options         `json:"log" yaml:"log"`
	Services map[string]*Application `json:"services" yaml:"services"`
}

Configuration defines the configuration struct.

func NewConfiguration

func NewConfiguration(v *viper.Viper) (*Configuration, error)

NewConfiguration creates a new configuration.

func (*Configuration) GetService

func (x *Configuration) GetService(name string) (*Application, error)

GetService is used to get the service by name.

type GRPC

type GRPC struct {
	URL  string `json:"url" yaml:"url"`
	Host string `json:"host" yaml:"host"`
	Port int    `json:"port" yaml:"port"`
}

GRPC defines the grpc struct.

func (*GRPC) GetAddr

func (x *GRPC) GetAddr() string

GetAddr is used to get the grpc address.

type HTTP

type HTTP struct {
	URL  string `json:"url" yaml:"url"`
	Host string `json:"host" yaml:"host"`
	Port int    `json:"port" yaml:"port"`
	Mode string `json:"mode" yaml:"mode"`
}

HTTP defines the http struct.

func (*HTTP) GetAddr

func (x *HTTP) GetAddr() string

GetAddr is used to get the http address.

Jump to

Keyboard shortcuts

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