config

package
v1.3.2 Latest Latest
Warning

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

Go to latest
Published: Jan 29, 2021 License: Apache-2.0 Imports: 13 Imported by: 21

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewService

func NewService(version, serviceType string, serviceName string, initFunc InitFunc) micro.Service

Builds and inits a new micro.Service object for use. The initFunc functor being asked for will be inserted into the services options as a BeforeStart which will be called DURING the service.Run invocation but BEFORE the service is fully up and operational. All of your initialization code that you need should go into this initFunc. If you don't need init code then feel free to use the NilInit function exported out of this package.

func NilInit

func NilInit(conf *Configuration) error

Types

type Config

type Config interface {
	Load(filename string) error
	NewConnectionString() (string, error)
	NewService(version, defaultName string) (micro.Service, error)
	AuthServiceName() (string, error)
	LookupService(serviceType string, serviceName string) (serviceFullName string)
}

type Configuration

type Configuration struct {
	Namespace string
	Database  struct {
		Driver         string
		Protocol       string
		Host           string
		Port           uint
		Database       string
		Username       string
		Password       string
		Options        string
		MaxConnections int `yaml:"maxConnections"`
	}
	Redis struct {
		Host     string
		Port     uint
		Password string
		Database int
	}
	Bot struct {
		BotToken        string   `yaml:"botToken"`
		DiscordServerId string   `yaml:"discordServerId"`
		BotRole         string   `yaml:"botRole"`
		IgnoredRoles    []string `yaml:"ignoredRoles"`
	}
	OAuth struct {
		ClientId         string `yaml:"clientId"`
		ClientSecret     string `yaml:"clientSecret"`
		CallBackProtocol string `yaml:"callBackProtocol"`
		CallBackHost     string `yaml:"callBackHost"`
		CallBackUrl      string `yaml:"callBackUrl"`
	} `yaml:"oauth"`
	Net struct {
		ListenHost string `yaml:"listenHost"`
		ListenPort int    `yaml:"listenPort"`
	}
	Discord struct {
		InviteUrl string `yaml:"inviteUrl"`
	} `yaml:"discord"`
	Registry struct {
		Hostname         string `yaml:"hostname"`
		Port             int    `yaml:"port"`
		RegisterTTL      int    `yaml:"registerTtl"`
		RegisterInterval int    `yaml:"registerInterval"`
	} `yaml:"registry"`
	Inputs []string `yaml:"inputs"`
	Chat   struct {
		Slack struct {
			Debug bool   `yaml:"debug"`
			Token string `yaml:"token"`
		} `yaml:"slack"`
		Discord struct {
			Token     string   `yaml:"token"`
			WhiteList []string `yaml:"whiteList"`
			Prefix    string   `yaml:"prefix"`
		} `yaml:"discord"`
	} `yaml:"chat"`
	Extensions map[interface{}]interface{} `yaml:"extensions"`
	// contains filtered or unexported fields
}

func (*Configuration) IsInitialized

func (c *Configuration) IsInitialized() bool

func (*Configuration) Load

func (c *Configuration) Load(filename string) error

func (*Configuration) LookupService

func (c *Configuration) LookupService(serviceType string, serviceName string) (serviceFullName string)

func (Configuration) NewConnectionString

func (c Configuration) NewConnectionString() (string, error)

type InitFunc

type InitFunc func(configuration *Configuration) error

Jump to

Keyboard shortcuts

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