Procyon|Docs
Configuration

Configuration Files

Load application settings from Procyon's default resources location.

Procyon looks for configuration in the resources/ directory. The default file name is procyon, so a typical application starts with resources/procyon.yml or resources/procyon.yaml.

Use this file for settings that belong to the application: server ports, integration endpoints, feature flags, timeouts, and package-specific options.

resources/procyon.yml
server:
  port: 8080
  readTimeout: 5

database:
  host: localhost
  port: 5432
  username: app
  password: secret

How files are loaded

Procyon registers the YAML property source loader during startup. The loader supports both yaml and yml extensions and turns nested YAML into dot-separated property names.

loader.go
loader := config.NewYamlPropertySourceLoader()
source, err := loader.Load(ctx, "resources/procyon.yml", resource)
if err != nil {
    return err
}

sources.PushBack(source)

Most applications do not need to call the loader directly. The application runtime uses registered loaders when it prepares the environment.

Nested keys

Nested YAML maps are flattened before values are resolved or bound:

resources/procyon.yml
mail:
  host: smtp.example.com
  port: 587
  tls: true

These values become:

properties
mail.host=smtp.example.com
mail.port=587
mail.tls=true

This is why the same mail prefix can be used with the binder later.

Custom file formats

You can support another file format by registering a component that implements config.PropertySourceLoader. The loader declares the extensions it supports and returns a PropertySource for the resolved resource.

json_loader.go
type JsonPropertySourceLoader struct{}

func NewJsonPropertySourceLoader() *JsonPropertySourceLoader {
    return &JsonPropertySourceLoader{}
}

func (l *JsonPropertySourceLoader) Extensions() []string {
    return []string{"json"}
}

func (l *JsonPropertySourceLoader) Load(
    ctx context.Context,
    name string,
    resource io.Resource,
) (config.PropertySource, error) {
    reader, err := resource.Reader()
    if err != nil {
        return nil, err
    }

    values := map[string]any{}
    if err := json.NewDecoder(reader).Decode(&values); err != nil {
        return nil, err
    }

    return config.NewMapPropertySource(name, values), nil
}

Register the loader like any other component:

components.go
func init() {
    component.Register(NewJsonPropertySourceLoader)
}

After registration, the standard data loader can use resources/procyon.json in the same configuration flow.