Documentation
¶
Index ¶
- Constants
- Variables
- func DisableTrace()
- func DumpIntrospectableInfo(obj Introspectable) string
- func EnableTrace()
- func SetTraceOutput(out *os.File)
- func Trace(format string, args ...any)
- func TraceWithWrapper(isWrapped bool, format string, args ...any)
- type AuxiliaryMethod
- type Entry
- type Introspectable
- type Method
- type Namespace
- type Package
- func (pkg *Package) Alias(alias, target string) bool
- func (pkg *Package) Export(name string) bool
- func (pkg *Package) GetDefault(op string) (string, bool)
- func (pkg *Package) IsExported(name string) bool
- func (pkg *Package) ResolveAlias(name string) string
- func (pkg *Package) SetDefault(operator, name string) bool
- func (pkg *Package) Unexport(name string)
- type Ref
- type Registry
- type ResolveResult
- type Respondable
- func (sr *Respondable) AddProtocol(name string)
- func (sr *Respondable) ConformsTo(name string) bool
- func (sr *Respondable) Invoke(evt events.Event) events.Event
- func (sr *Respondable) ListProtocols() []string
- func (sr *Respondable) MetadataForSelector(selector string) (map[string]string, error)
- func (sr *Respondable) Methods() *Table
- func (sr *Respondable) Name() string
- func (sr *Respondable) RespondsTo(evt events.Event) bool
- func (sr *Respondable) Selectors() []string
- func (sr *Respondable) SortedSelectors() []string
- func (sr *Respondable) Type() string
- type SelectorError
- type SelectorEvent
- type Table
- func (st *Table) AddAfter(selector string, method Method) error
- func (st *Table) AddAfterWithPriority(priority int, selector string, method Method) error
- func (st *Table) AddBefore(selector string, method Method) error
- func (st *Table) AddBeforeWithPriority(priority int, selector string, method Method) error
- func (st *Table) AllMetadata() map[string]map[string]string
- func (st *Table) Get(name string) (*Entry, bool)
- func (st *Table) HasSelector(selector string) bool
- func (st *Table) InvokeSelector(sel string, tgt responder.Respondable, evt events.Event) (events.Event, bool)
- func (st *Table) InvokeSelectorAsync(ctx context.Context, sel string, tgt responder.Respondable, evt events.Event) <-chan events.Event
- func (st *Table) ListMetadata(selector string) (map[string]string, error)
- func (st *Table) Metadata(selector string) (metadata.Metadata, error)
- func (st *Table) MustMetadata(selector string) metadata.Metadata
- func (st *Table) Register(selector string, method Method)
- func (st *Table) SetDefault(selector string)
- func (st *Table) SetMaxForwardDepth(val int)
- func (st *Table) SetPrimary(selector string, method Method) (Method, error)
- func (st *Table) Unregister(selector string)
Constants ¶
const (
DefaultPriority = int(100)
)
Variables ¶
var ( ErrForwardLoop = errors.Base("selector forward loop detected") ErrHasNoSelector = errors.Base("has no selector") ErrNoMethodExists = errors.Base("no method by this name exists") ErrNoMethodSpecified = errors.Base("no method specified") ErrNoMethodToWrap = errors.Base("no method to wrap") ErrReferenceParse = errors.Base("reference parse failure") ErrSelectorNotFound = errors.Base("no method for selector") ErrSelectorPanic = errors.Base("panic during selector method") ErrUnresolved = errors.Base("unresolved selector") )
Functions ¶
func DisableTrace ¶
func DisableTrace()
func DumpIntrospectableInfo ¶
func DumpIntrospectableInfo(obj Introspectable) string
func EnableTrace ¶
func EnableTrace()
func SetTraceOutput ¶
func TraceWithWrapper ¶
Types ¶
type AuxiliaryMethod ¶
type AuxiliaryMethod struct {
// contains filtered or unexported fields
}
type Introspectable ¶
type Introspectable interface {
responder.Respondable
// Return a list of selectors.
Selectors() []string
// Return a list of sorted selectors
SortedSelectors() []string
// Return a list of methods that the object can respond to.
Methods() *Table
// Does the object conform to the given protocol?
ConformsTo(protocol string) bool
// List all protocols for which the object claims conformity.
ListProtocols() []string
// Return a map of metadata for a selector
MetadataForSelector(string) (map[string]string, error)
}
Objects that implement these methods are considered `introspectable` and are deemed capable of being asked to describe themselves in various ways.
type Package ¶
Packages.
A package provides a table of selectors, aliases, and defaults.
func NewPackage ¶
func (*Package) GetDefault ¶
Returns the default for the given operation.
func (*Package) IsExported ¶
Is the given selector exported?
func (*Package) ResolveAlias ¶
Resolve a selector.
If the specified selector is an alias, then its target is returned.
func (*Package) SetDefault ¶
Sets a default selector.
type Ref ¶
type Registry ¶
type Registry struct {
GlobalDefault *Package
// contains filtered or unexported fields
}
func NewRegistry ¶
func NewRegistry() *Registry
func (*Registry) AddPackage ¶
type ResolveResult ¶
func (ResolveResult) String ¶
func (r ResolveResult) String() string
type Respondable ¶
type Respondable struct {
// contains filtered or unexported fields
}
func NewRespondable ¶
func NewRespondable(name, typeName string) *Respondable
func (*Respondable) AddProtocol ¶
func (sr *Respondable) AddProtocol(name string)
func (*Respondable) ConformsTo ¶
func (sr *Respondable) ConformsTo(name string) bool
func (*Respondable) ListProtocols ¶
func (sr *Respondable) ListProtocols() []string
func (*Respondable) MetadataForSelector ¶
func (sr *Respondable) MetadataForSelector(selector string) (map[string]string, error)
func (*Respondable) Methods ¶
func (sr *Respondable) Methods() *Table
func (*Respondable) Name ¶
func (sr *Respondable) Name() string
func (*Respondable) RespondsTo ¶
func (sr *Respondable) RespondsTo(evt events.Event) bool
func (*Respondable) Selectors ¶
func (sr *Respondable) Selectors() []string
func (*Respondable) SortedSelectors ¶
func (sr *Respondable) SortedSelectors() []string
func (*Respondable) Type ¶
func (sr *Respondable) Type() string
type SelectorError ¶
type SelectorError struct {
// contains filtered or unexported fields
}
Selector error event.
NOTE: `golangci-lint` will want this to be called `Error', and that is not what we want. This is an explicit event, not to be confused with `events.Error`.
func NewSelectorError ¶
func NewSelectorError(err error) *SelectorError
func (*SelectorError) Error ¶
func (e *SelectorError) Error() error
func (*SelectorError) Selector ¶
func (e *SelectorError) Selector() string
func (*SelectorError) String ¶
func (e *SelectorError) String() string
func (*SelectorError) When ¶
func (e *SelectorError) When() time.Time
type SelectorEvent ¶
This interface represents a Selector-specific event.
NOTE: `golangci-lint` will want this to be called `Event`. this is a bad idea because this type is explicitly for selector-specific events, and should not be confused with `events.Event`.
type Table ¶
type Table struct {
// contains filtered or unexported fields
}
Map selector names to method implementations.
func (*Table) AddAfterWithPriority ¶
func (*Table) AddBeforeWithPriority ¶
func (*Table) HasSelector ¶
Check whether a selector is defined.