registry

package
v0.0.0-...-3a9fddd Latest Latest
Warning

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

Go to latest
Published: Nov 1, 2024 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func New

func New() *registry

func Register

func Register(reg Registry, v Registrable, s Serializer, d Deserializer, os []BuildOption) error

func RegisterFactory

func RegisterFactory(reg Registry, key string, fn func() interface{}, s Serializer, d Deserializer,
	os []BuildOption,
) error

func RegisterKey

func RegisterKey(reg Registry, key string, v interface{}, s Serializer, d Deserializer, os []BuildOption) error

Types

type BuildOption

type BuildOption func(v interface{}) error

func ValidateImplements

func ValidateImplements(checkV interface{}) BuildOption

ValidateImplements will verify that the built value implements the given interface

Pass interfaces using "(*I)(nil)", like in this example:

type MyInterface interface {
    MyMethod(int) bool
}

ValidateImplements((*MyInterface)(nil))

You will only be able to validate interfaces with exported methods, you will not be able to validate any that have one or more unexported methods.

type Deserializer

type Deserializer func(d []byte, v interface{}) error

type Registrable

type Registrable interface {
	Key() string
}

type Registry

type Registry interface {
	Serialize(key string, v interface{}) ([]byte, error)
	Build(key string, options ...BuildOption) (interface{}, error)
	Deserialize(key string, data []byte, options ...BuildOption) (interface{}, error)
	// contains filtered or unexported methods
}

type Serde

type Serde interface {
	Register(v Registrable, options ...BuildOption) error
	RegisterKey(key string, v interface{}, options ...BuildOption) error
	RegisterFactory(key string, fn func() interface{}, options ...BuildOption) error
}

type Serializer

type Serializer func(v interface{}) ([]byte, error)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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