ident

package
v0.0.0-...-883aa5b Latest Latest
Warning

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

Go to latest
Published: Dec 16, 2024 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetByIdent

func GetByIdent(ctx context.Context, ident Ident) (model.Node, error)

func RegisterIdentType

func RegisterIdentType[K comparable, T model.Node](key K, typeName string, lookup func(ctx context.Context, id Ident) (T, error))

RegisterIdentType registers a new ident type with the given key, type name and lookup function.

typeName must be globally unique and should be as short as possible. The lookup function must be able to retrieve the node associated with the given ident. The function will panic if lookup is nil, or if the key or the typeName is already registered.

This function is typically called during the initialization phase of the packages that defines unique identifiers by using the init() function.

Types

type Ident

type Ident struct {
	ID   string
	Type string
}

func NewIdent

func NewIdent[K comparable](t K, id ...string) Ident

NewIdent returns a new ident with the given type and id parts. The type must already be registered by using the RegisterIdentType function.

func (Ident) MarshalGQLContext

func (i Ident) MarshalGQLContext(_ context.Context, w io.Writer) error

func (Ident) Parts

func (i Ident) Parts() []string

func (Ident) String

func (i Ident) String() string

func (*Ident) UnmarshalGQLContext

func (i *Ident) UnmarshalGQLContext(_ context.Context, v interface{}) error

type Lookup

type Lookup func(ctx context.Context, id Ident) (model.Node, error)

Jump to

Keyboard shortcuts

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