format

package
v0.0.0-...-678bb0e Latest Latest
Warning

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

Go to latest
Published: Aug 8, 2017 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Overview

Package format implements a config client Backend that performs formatting on items.

The available formats are registered during init() time via 'Register'.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ClearRegistry

func ClearRegistry()

ClearRegistry removes all registered formatters.

Useful in tests that call Register to setup initial state.

func Register

func Register(rk string, f Formatter)

Register registers a Formatter implementation for given format.

If the supplied key is already registered, Register will panic.

Types

type Backend

type Backend struct {
	// B is the underlying Backend that this Backend will pull data
	// from.
	backend.B
}

Backend is a backend.B implementation that applies Formatter transformations to the various Items that pass through it.

Formatter transformations are registered explicitly to the Resolver descriptions of the types that they operate on. If an Item is already formatted, no further transformations will be applied.

func (*Backend) Get

func (b *Backend) Get(c context.Context, configSet, path string, p backend.Params) (*backend.Item, error)

Get implements backend.B.

func (*Backend) GetAll

func (b *Backend) GetAll(c context.Context, t backend.GetAllTarget, path string, p backend.Params) (
	[]*backend.Item, error)

GetAll implements backend.B.

type Formatter

type Formatter interface {
	FormatItem(c, fd string) (string, error)
}

Formatter applies a transformation to the data's cached representation.

The Formatter is supplied with the content to format along with the formatter-specific metadata, fd.

Formatter operates on a backend.Item's Content via the "format" Backend.

Jump to

Keyboard shortcuts

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