config

package
v0.0.0-...-2af547a Latest Latest
Warning

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

Go to latest
Published: Apr 10, 2020 License: AGPL-3.0 Imports: 10 Imported by: 16

Documentation

Overview

Package config contains configuration-related code for Pullcord

Index

Constants

View Source
const ReferenceResourceTypeName = "ref"

ReferenceResourceTypeName is the reserved name to indicate a placeholder for an already registered resource instead of giving the type for for a new resource being defined.

View Source
const UnexpectedResourceType = errors.New(
	"The requested resource does not have the expected type",
)

UnexpectedResourceType indicates that a sub-resource did not have an expected type.

Variables

This section is empty.

Functions

func MustRegisterResourceType

func MustRegisterResourceType(
	typeName string,
	newFunc func() json.Unmarshaler,
)

MustRegisterResourceType is a convenience function around RegisterResourceType that panics on error.

func RegisterResourceType

func RegisterResourceType(
	typeName string,
	newFunc func() json.Unmarshaler,
) error

RegisterResourceType is an infrastructure hack that allows new config Resource types to be specified at run-time. It needs to be run before a Parser is used, presumably in an Init function of the package of a config plugin.

Types

type HTTPMultiServer

type HTTPMultiServer struct {
	Listeners []net.Listener
	Handler   http.Handler
}

HTTPMultiServer implements the Pullcord server interface with an HTTP handler and multiple listeners.

func (*HTTPMultiServer) Close

func (s *HTTPMultiServer) Close() error

Close implements .../pullcord/Server.

func (*HTTPMultiServer) Serve

func (s *HTTPMultiServer) Serve() error

Serve implements .../pullcord/Server.

func (*HTTPMultiServer) UnmarshalJSON

func (s *HTTPMultiServer) UnmarshalJSON(d []byte) error

UnmarshalJSON implements encoding/json.Unmarshaler.

type HTTPServer

type HTTPServer struct {
	Listener net.Listener
	Handler  http.Handler
}

HTTPServer implements the Pullcord server interface with an HTTP handler.

func (*HTTPServer) Close

func (s *HTTPServer) Close() error

Close implements .../pullcord.Server.

func (*HTTPServer) Serve

func (s *HTTPServer) Serve() error

Serve implements .../pullcord.Server.

func (*HTTPServer) UnmarshalJSON

func (s *HTTPServer) UnmarshalJSON(d []byte) error

UnmarshalJSON implements encoding/json.Unmarshaler.

type Parser

type Parser struct {
	Reader io.Reader
}

Parser extracts configuration info from an io.Reader.

func (Parser) Server

func (p Parser) Server() (pullcord.Server, error)

Server extracts the .../pullcord.Server component from the config io.Reader.

type Resource

type Resource struct {
	Unmarshalled json.Unmarshaler
	// contains filtered or unexported fields
}

Resource represents a configurable object which allows an arbitrary JSON blob to be turned into an implementation of whatever type it specifies. This abstraction is the key to allowing instantiation of structs which have interface members instead of just non-abstracted data types.

func (*Resource) UnmarshalJSON

func (rsc *Resource) UnmarshalJSON(input []byte) error

UnmarshalJSON implements encoding/json.Unmarshaler, which is the core requirement which allows these resources to be instantiated at all.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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