rest

package
v0.27.0 Latest Latest
Warning

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

Go to latest
Published: Sep 17, 2023 License: MIT Imports: 10 Imported by: 0

Documentation

Overview

Package rest defines the REST connection source creation strategy to be integrated into the config package source factory instance.

Index

Constants

View Source
const (
	// ID defines the application container registration string for the
	// rest source creation strategy.
	ID = source.ID + ".rest"
	// ObsID defines the application container registration string for the
	// observable rest source creation strategy.
	ObsID = ID + "-observable"
)
View Source
const (
	// ObsType defines the value to be used to
	// declare an observable rest config source type.
	ObsType = "observable-rest"
)
View Source
const (
	// Type defines the value to be used to declare a
	// rest config source type.
	Type = "rest"
)

Variables

View Source
var (
	// ErrConfigNotFound defines a rest response
	// config not found error.
	ErrConfigNotFound = fmt.Errorf("rest config source config not found")

	// ErrTimestampNotFound defines a rest response
	// timestamp not found error.
	ErrTimestampNotFound = fmt.Errorf("rest config source timestamp not found")
)

Functions

This section is empty.

Types

type ObsSource

type ObsSource struct {
	Source
	// contains filtered or unexported fields
}

ObsSource defines a config source that read a REST service and store a section of the response as the stored config. Also, the REST service will be periodically checked for updates.

func NewObsSource

func NewObsSource(
	client requester,
	uri,
	format string,
	decoderCreator decoderCreator,
	timestampPath,
	configPath string,
) (*ObsSource, error)

NewObsSource will instantiate a new configuration source that will read a REST endpoint for configuration info, opening the possibility for on-the-fly update on source content change.

func (*ObsSource) Reload

func (s *ObsSource) Reload() (bool, error)

Reload will check if the source has been updated, and, if so, reload the source configuration content.

type ObsSourceStrategy

type ObsSourceStrategy struct {
	SourceStrategy
}

ObsSourceStrategy defines a strategy used to instantiate an observable REST service config source creation strategy.

func NewObsSourceStrategy

func NewObsSourceStrategy(
	decoderFactory *config.DecoderFactory,
) (*ObsSourceStrategy, error)

NewObsSourceStrategy instantiates a new observable REST service config source creation strategy.

func (ObsSourceStrategy) Accept

func (s ObsSourceStrategy) Accept(
	cfg config.Partial,
) bool

Accept will check if the source dFactory strategy can instantiate a source where the data to check comes from a configuration instance.

func (ObsSourceStrategy) Create

func (s ObsSourceStrategy) Create(
	cfg config.Partial,
) (config.Source, error)

Create will instantiate the desired rest source instance where the initialization data comes from a configuration instance.

type Provider

type Provider struct{}

Provider defines the slate.config module service provider to be used on the application initialization to register the config service.

func (Provider) Boot

func (p Provider) Boot(
	container *slate.Container,
) error

Boot will start the configuration config instance by calling the configuration loader with the defined provider base entry information.

func (Provider) Register

func (Provider) Register(
	container *slate.Container,
) error

Register will register the configuration section instances in the application container.

type Source

type Source struct {
	source.Source
	// contains filtered or unexported fields
}

Source defines a config source that read a REST service and store a section of the response as the stored config.

func NewSource

func NewSource(
	client requester,
	uri,
	format string,
	decoderCreator decoderCreator,
	configPath string,
) (*Source, error)

NewSource will instantiate a new configuration source that will read a REST endpoint for configuration info.

type SourceStrategy

type SourceStrategy struct {
	// contains filtered or unexported fields
}

SourceStrategy defines a strategy used to instantiate a REST service config source creation strategy.

func NewSourceStrategy

func NewSourceStrategy(
	decoderFactory *config.DecoderFactory,
) (*SourceStrategy, error)

NewSourceStrategy instantiates a new REST service config source creation strategy.

func (SourceStrategy) Accept

func (s SourceStrategy) Accept(
	cfg config.Partial,
) bool

Accept will check if the source factory strategy can instantiate a source where the data to check comes from a configuration instance.

func (SourceStrategy) Create

func (s SourceStrategy) Create(
	cfg config.Partial,
) (config.Source, error)

Create will instantiate the desired rest source instance where the initialization data comes from a configuration instance.

Jump to

Keyboard shortcuts

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