Documentation
¶
Overview ¶
Package unit names a unit of work by its provider and the provider's key.
Index ¶
- func KeysEqual(c Codec, a, b string) bool
- func UseLabels(r *Registry)
- func ValidProvider(id string) bool
- type Anchor
- type Codec
- type Equaler
- type KeyComparer
- type Labeler
- type Linker
- type Locator
- type OpaqueCodec
- type ProviderID
- type Registry
- func (r *Registry) Codec(p ProviderID) (Codec, bool)
- func (r *Registry) KeysEqual(p ProviderID, a, b string) bool
- func (r *Registry) Linked(p ProviderID) bool
- func (r *Registry) Parse(provider, key string) (Unit, error)
- func (r *Registry) ParseURL(raw string) (Unit, bool)
- func (r *Registry) Providers() []ProviderID
- func (r *Registry) Same(a, b Unit) bool
- func (r *Registry) Target(p ProviderID) string
- func (r *Registry) Targets(ps ...ProviderID) string
- func (r *Registry) URL(u Unit) (string, bool)
- type Resolver
- type Targeter
- type Unit
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func KeysEqual ¶ added in v0.2.0
KeysEqual says whether keys a and b of c's provider name the same thing.
func UseLabels ¶ added in v0.3.0
func UseLabels(r *Registry)
UseLabels makes r's codecs the ones Unit.Label asks. The composition root sets it once, before anything labels a unit.
func ValidProvider ¶ added in v0.2.0
ValidProvider says whether id has a provider id's shape: a lowercase letter, then up to 31 lowercase letters, digits, dashes or underscores.
Types ¶
type Anchor ¶
type Anchor struct {
Unit Unit `json:"unit"`
Ref string `json:"ref"` // slack "<conversation>/<ts>"; github "review:<id>", "comment:<id>", "commit:<oid>", "situation:<kind>"; "turn:<round>"; "row:<rev>"; "draft:<id>", "draft:<id>:<kind>" before v4
Permalink string `json:"permalink,omitempty"`
At time.Time `json:"at,omitzero"`
}
Anchor is a plugin's opaque reference to a message or event inside a unit.
type Codec ¶
type Codec interface {
Provider() ProviderID
Valid(key string) error
}
Codec validates the keys of one provider.
type Equaler ¶ added in v0.2.0
Equaler is an optional capability of a Codec: whether two keys of its provider name the same thing, such as logins compared without case. A codec without it compares keys byte for byte.
type KeyComparer ¶ added in v0.2.0
type KeyComparer interface {
KeysEqual(p ProviderID, a, b string) bool
}
KeyComparer says whether two keys of provider p name the same thing.
type Labeler ¶ added in v0.3.0
Labeler is an optional capability of a Codec: how a person reads a key.
type Linker ¶ added in v0.2.0
Linker is an optional capability of a Codec: the web address of a key, and the key an address names. A unit of a provider with addresses is named by its address wherever a person or an agent types it.
type Locator ¶ added in v0.2.0
Locator knows the unit a local checkout's directory holds, such as the pull request of its branch; ok is false when it holds none.
type OpaqueCodec ¶
type OpaqueCodec struct{ ID ProviderID }
OpaqueCodec accepts any non-blank key without a line break.
func (OpaqueCodec) Provider ¶
func (c OpaqueCodec) Provider() ProviderID
func (OpaqueCodec) Valid ¶
func (c OpaqueCodec) Valid(key string) error
type ProviderID ¶
type ProviderID string
const ( GitHub ProviderID = "github" Session ProviderID = "session" Workspace ProviderID = "workspace" // Task is the provider the core keeps for tasks: the key is the // task's id. Task ProviderID = "task" )
type Registry ¶
type Registry struct {
// contains filtered or unexported fields
}
func NewRegistry ¶
func (*Registry) Codec ¶ added in v0.2.0
func (r *Registry) Codec(p ProviderID) (Codec, bool)
Codec is p's codec.
func (*Registry) KeysEqual ¶ added in v0.2.0
func (r *Registry) KeysEqual(p ProviderID, a, b string) bool
KeysEqual says whether keys a and b of p name the same thing through p's codec; a provider r does not know compares byte for byte.
func (*Registry) Linked ¶ added in v0.2.0
func (r *Registry) Linked(p ProviderID) bool
Linked says whether p's units have web addresses.
func (*Registry) ParseURL ¶ added in v0.2.0
ParseURL is the unit a web address names, among the providers with addresses.
func (*Registry) Providers ¶
func (r *Registry) Providers() []ProviderID
func (*Registry) Target ¶ added in v0.2.0
func (r *Registry) Target(p ProviderID) string
Target is how a command line names a unit of p: its codec's Target, else <p:key>.
func (*Registry) Targets ¶ added in v0.2.0
func (r *Registry) Targets(ps ...ProviderID) string
Targets is how a command line names a unit of any of ps, or of any provider of r when ps is empty: their targets as one, such as <url|ref|permalink|slack:key>.
type Resolver ¶ added in v0.2.0
type Resolver interface {
Resolve(ctx context.Context, address string) (key string, ok bool, err error)
}
Resolver is a codec whose provider must look an address up to find its unit, such as a Slack message ref or permalink to its direct message segment or thread; ok is false for an address that is not one of the provider's.
type Targeter ¶ added in v0.2.0
type Targeter interface {
Target() string
}
Targeter is an optional capability of a Codec: how a command line names one of its units, such as <url>.
type Unit ¶
type Unit struct {
Provider ProviderID `json:"provider"`
Key string `json:"key"`
}
func ParseAddress ¶ added in v0.3.0
ParseAddress is the unit a web address names, as the codecs of the registry UseLabels set read it; false for an address none of them has.
func (Unit) Address ¶ added in v0.3.0
Address names u as a person or an agent types it: as its web address when the codec of its provider in the registry UseLabels set has one, else as provider:key.
func (Unit) Label ¶
Label names u as users read it: as the codec of its provider in the registry UseLabels set labels its key, else as provider:key.