config

package
v1.4.0 Latest Latest
Warning

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

Go to latest
Published: Dec 22, 2023 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Module = fx.Module(
	"appconfig",
	fx.Provide(
		func(log *zap.Logger) Config {
			if err := config.LoadConfig(&defaultConfig); err != nil {
				log.Error("Error loading config", zap.Error(err))
			}

			return defaultConfig
		},
	),
	fx.Provide(func(cfg Config) http.Config {
		return http.Config{
			Listen: cfg.HTTP.Listen,
		}
	}),
	fx.Provide(func(cfg Config) db.Config {
		return db.Config{
			Dialect:  cfg.Database.Dialect,
			Host:     cfg.Database.Host,
			Port:     cfg.Database.Port,
			User:     cfg.Database.User,
			Password: cfg.Database.Password,
			Database: cfg.Database.Database,
			Timezone: cfg.Database.Timezone,
		}
	}),
	fx.Provide(func(cfg Config) services.PushServiceConfig {
		return services.PushServiceConfig{
			CredentialsJSON: cfg.FCM.CredentialsJSON,
		}
	}),
	fx.Provide(func(cfg Config) tasks.HashingTaskConfig {
		return tasks.HashingTaskConfig{
			Interval: time.Duration(cfg.Tasks.Hashing.IntervalSeconds) * time.Second,
		}
	}),
)

Functions

This section is empty.

Types

type Config

type Config struct {
	HTTP     HTTP      `yaml:"http"`
	Database Database  `yaml:"database"`
	FCM      FCMConfig `yaml:"fcm"`
	Tasks    Tasks     `yaml:"tasks"`
}

type Database

type Database struct {
	Dialect  string `yaml:"dialect" envconfig:"DATABASE__DIALECT"`
	Host     string `yaml:"host" envconfig:"DATABASE__HOST"`
	Port     int    `yaml:"port" envconfig:"DATABASE__PORT"`
	User     string `yaml:"user" envconfig:"DATABASE__USER"`
	Password string `yaml:"password" envconfig:"DATABASE__PASSWORD"`
	Database string `yaml:"database" envconfig:"DATABASE__DATABASE"`
	Timezone string `yaml:"timezone" envconfig:"DATABASE__TIMEZONE"`
}

type FCMConfig

type FCMConfig struct {
	CredentialsJSON string `yaml:"credentials_json"`
}

type HTTP

type HTTP struct {
	Listen string `yaml:"listen" envconfig:"HTTP__LISTEN"`
}

type HashingTask added in v1.4.0

type HashingTask struct {
	IntervalSeconds uint16 `yaml:"interval_seconds"`
}

type Tasks added in v1.4.0

type Tasks struct {
	Hashing HashingTask `yaml:"hashing"`
}

Jump to

Keyboard shortcuts

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