scheme

package
v0.1.20 Latest Latest
Warning

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

Go to latest
Published: Sep 15, 2022 License: MIT Imports: 4 Imported by: 6

Documentation

Index

Constants

This section is empty.

Variables

View Source
var KnownTypesRegistryInstance = NewKnownTypesRegistry()

KnownTypesRegistryInstance is a default global types registry

Functions

func GetStructType

func GetStructType(obj Object) reflect.Type

GetStructType returns reflect.Type of the passed object

Types

type Group

type Group string

func (Group) Empty

func (gv Group) Empty() bool

Empty returns true if group is empty

func (Group) String

func (gv Group) String() string

String puts "group" into a string, it's possible in the future for this type to change

type GroupKind

type GroupKind struct {
	Group Group
	Kind  string
}

GroupKind specifies a Group and a Kind

func FromString

func FromString(str string) (GroupKind, error)

func (GroupKind) Empty

func (gk GroupKind) Empty() bool

func (GroupKind) Identifier

func (gk GroupKind) Identifier() string

Identifier used as uniq key in schema

func (GroupKind) String

func (gk GroupKind) String() string

type KnownTypesRegistry

type KnownTypesRegistry interface {
	// AddKnownTypes registers list of types of objects to a Group. Kind of each type will be set as struct name using reflection
	AddKnownTypes(g Group, types ...Object)
	// AddKnownTypeWithName registers a type an object to a Group and custom defined Kind
	AddKnownTypeWithName(gk GroupKind, obj Object)
	// NewObject instantiates new object instance of a type registered behind GroupKind
	NewObject(gk GroupKind) (Object, error)
	// ObjectKind returns GroupKind of an already registered type
	ObjectKind(object Object) (*GroupKind, error)
}

func NewKnownTypesRegistry

func NewKnownTypesRegistry() KnownTypesRegistry

NewKnownTypesRegistry returns new empty registry of types

type Object

type Object interface {
	GroupKind() GroupKind
	SetGroupKind(gk *GroupKind)
}

Object interface must be supported by all message types registered with Scheme. Since objects in a scheme are expected to be marshalled to the wire, the interface an Object must provide to the Scheme allows marshallers to set the kind, and group the object is represented as

type TypeMeta

type TypeMeta struct {
	Kind  string `json:"kind,omitempty" protobuf:"bytes,1,opt,name=kind"`
	Group string `json:"group,omitempty" protobuf:"bytes,2,opt,name=group"`
}

func (TypeMeta) GroupKind

func (t TypeMeta) GroupKind() GroupKind

func (*TypeMeta) SetGroupKind

func (t *TypeMeta) SetGroupKind(gk *GroupKind)

Jump to

Keyboard shortcuts

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