跳到主要内容

Configuration

Configuration is based on Kratos Config and data format is defined as Protobuf

VFS Integration

import(
...
kitconf "github.com/go-saas/kit/pkg/conf"
)
flag.Parse()

source := []config.Source{
env.NewSource("KRATOS_"),
}
if flagconf == nil {
flagconf = append(flagconf, "./configs")
}
for _, s := range flagconf {
v := vfs.New()
//mount filter config files
v.Mount("/", afero.NewRegexpFs(afero.NewBasePathFs(afero.NewOsFs(), strings.TrimSpace(s)), regexp.MustCompile(`\.(json|proto|xml|yaml)$`)))
//vfs as configuration source
source = append(source, kitconf.NewVfs(v, "/"))
}

c := config.New(
config.WithSource(
source...,
),
)
defer c.Close()
if err := c.Load(); err != nil {
panic(err)
}

Common Configuration

  • data:
    • endpoints:
      • databases: database dsn
      • events: distributed eventbus
      • redis: distributed key-value database
      • email: email sender
      • sms: sms sender
    • vfs: virtual file system mount paths
  • security:
  • services:
    • services: configuration for registry
    • servers: server config
    • clients: server to server communication client
    • registry: registry
  • logging: logging
  • tracing: tracing
  • app: application config
  • dev: development config
  • stripe: stripe config

Modules Configuration

Refer to modules