config.go 548 B

123456789101112131415161718192021222324252627282930
  1. package config
  2. import (
  3. "fmt"
  4. _interface "git.beejay.kim/Craft/Api/database/interface"
  5. "time"
  6. )
  7. type Configuration struct {
  8. Timeout int `yaml:"timeout"`
  9. Issuer string `yaml:"issuer"`
  10. Database _interface.Databases `yaml:"database"`
  11. }
  12. func (c Configuration) Invalidate() error {
  13. if c.Timeout < 1 {
  14. c.Timeout = 30
  15. }
  16. if c.Issuer == "" {
  17. return fmt.Errorf("`issuer` must not be an empty string")
  18. }
  19. return Invalidate(c)
  20. }
  21. func (c Configuration) TimeoutDuration() time.Duration {
  22. return time.Duration(c.Timeout) * time.Second
  23. }