writer

package module
v0.9.7 Latest Latest
Warning

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

Go to latest
Published: Oct 25, 2023 License: BSD-3-Clause Imports: 11 Imported by: 0

README

go-writer-config

Go package implementing the whosonfirst/go-writer/v3 interfaces to provide methods for creating a new whosonfirst/go-writer/v3.MultiWriter instance derived from a JSON-encoded config file.

Documentation

Go Reference

See also

Documentation

Overview

Package writer implements the `whosonfirst/go-writer/v2` interfaces to provide methods for creating a new `whosonfirst/go-writer/v2.MultiWriter` instance derived from a JSON-encoded config file.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewConfigWriter

func NewConfigWriter(ctx context.Context, uri string) (wof_writer.Writer, error)

NewConfigWriter return a new `go-writer/v2.Writer` instance derived from 'uri' which is expected to take the form of:

config://{ENVIRONMENT}/{TARGET}?config={VALID_GOCLOUD_DEV_RUNTIMEVAR_URI}

For example:

config://dev/test?config=file:///usr/local/config.json&async=true

func NewConfigWriterFromOptions

func NewConfigWriterFromOptions(ctx context.Context, opts *ConfigWriterOptions) (wof_writer.Writer, error)

NewConfigWriterFromOptions return a new `go-writer/v2.Writer` instance derived from 'opts'.

Types

type ConfigWriterOptions

type ConfigWriterOptions struct {
	// Config is a `WriterConfig` instance containing configuration data for instantiating one or more `go-writer/v2.Writer` instances.
	Config *WriterConfig
	// Exclude is an optional list of string labels to compare against individual `RuntimevarConfig.Label` values; if there is a match that `RuntimevarConfig` instance will be excluded
	Exclude []string
	// Target is the string label mapped to the list of `RuntimevarConfig` instances used to create a new `go-writer/v2.Writer` instance.
	Target string
	// Environment is the string label mapped to the `TargetConfig` instance used to create a new `go-writer/v2.Writer` instance.
	Environment string
	// Async is an optional boolean value to signal that a new asynchronous `go-writer/v2.MultiWriter` instance should be created.
	Async bool
	// Verbose is an optional boolean value to signal to the underlying `go-writer/v2.MultiWriter` instance that it should be verbose in logging events.
	Verbose bool
	// An options `*log.Logger` instance to pass to the underlying `go-writer/v2.MultiWriter` instance.
	Logger *log.Logger
}

ConfigWriterOptions is a struct containing configuration options for create a new `go-writer/v2.MultiWriter` instance derived from a JSON configuration file

type RuntimevarConfig

type RuntimevarConfig struct {
	// The scheme of the gocloud.dev/runtimevar URI to build
	Runtimevar string `json:"runtimevar"`
	// The value of the gocloud.dev/runtimevar URI to build
	Value string `json:"value"`
	// An optional gocloud.dev/runtimevar URI used to replace the string "{credentials}" in `Value`.
	Credentials string `json:"credentials,omitempty"`
	// An optional boolean flag used to flag the config as currently disabled.
	Disabled bool `json:"disabled,omitempty"`
	// An optional string label used to match any "?exclude={LABEL}" parameters in a `whosonfirst/go-writer/v2` URI constuctor; this allows individual configs to be disabled at runtime
	Label string `json:"label,omitempty"`
}

type RuntimevarConfig defines a struct for configuration data used to build a gocloud.dev/runtimevar URI which are used to resolve final `whosonfirst/go-writer/v2` URIs.

type TargetConfig

type TargetConfig map[string][]*RuntimevarConfig

type TargetConfig is a map where the keys are arbitrary labels (string) mapped to a list `RuntimevarConfig` instances.

func (*TargetConfig) RuntimevarConfigs

func (cfg *TargetConfig) RuntimevarConfigs(target string) ([]*RuntimevarConfig, bool)

RuntimevarConfigs returns the list of `RuntimevarConfig` instances associated with the key 'target'.

type WriterConfig

type WriterConfig map[string]*TargetConfig

type WriterConfig is a map where the keys are arbitrary labels (strings) mapped to `TargetConfig` instances.

func (*WriterConfig) Target

func (cfg *WriterConfig) Target(environment string) (*TargetConfig, bool)

Target returns the `TargetConfig` instance associated with the key 'target'.

Jump to

Keyboard shortcuts

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