nelson

package
v0.0.0-...-2c4dd60 Latest Latest
Warning

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

Go to latest
Published: Jun 20, 2022 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ValueKey       = state.Keypath("value")
	ContentTypeKey = state.Keypath("Content-Type")
)

Functions

func ContentTypeOf

func ContentTypeOf(node state.Node) (string, error)

func FirstNonFrameNode

func FirstNonFrameNode(node state.Node, maxDepth uint64) (state.Node, error)

Recurses down through a series of Frame nodes until it finds a non-Frame node and returns it. If maxDepth is exceeded, errors.Err404 is returned.

func ParseStateLink(linkValue string) (stateURI string, keypath state.Keypath, version *state.Version, _ error)

ParseStateLink parses state links of the form "<state URI>[/<keypath>][@<version>]".

Types

type BlobFrame

type BlobFrame struct {
	Frame
	// contains filtered or unexported fields
}

func (BlobFrame) BytesReader

func (frame BlobFrame) BytesReader(rng *types.Range) (io.ReadCloser, int64, error)

func (BlobFrame) BytesValue

func (frame BlobFrame) BytesValue(keypath state.Keypath) ([]byte, bool, error)

func (BlobFrame) ContentLength

func (frame BlobFrame) ContentLength() (int64, error)

func (BlobFrame) MarshalJSON

func (frame BlobFrame) MarshalJSON() ([]byte, error)

func (BlobFrame) NodeAt

func (frame BlobFrame) NodeAt(keypath state.Keypath, rng *state.Range) state.Node

func (BlobFrame) ParentNodeFor

func (frame BlobFrame) ParentNodeFor(keypath state.Keypath) (state.Node, state.Keypath)

func (BlobFrame) StringValue

func (f BlobFrame) StringValue(keypath state.Keypath) (string, bool, error)

type BlobResolver

type BlobResolver interface {
	HaveBlob(blobID blob.ID) (bool, error)
	Manifest(blobID blob.ID) (blob.Manifest, error)
	BlobReader(blobID blob.ID, byteRange *types.Range) (io.ReadCloser, int64, error)
}

type Frame

type Frame struct {
	state.Node
	// contains filtered or unexported fields
}

func (Frame) BytesReader

func (f Frame) BytesReader(rng *types.Range) (io.ReadCloser, int64, error)

func (Frame) ContentLength

func (frame Frame) ContentLength() (int64, error)

func (Frame) ContentType

func (frame Frame) ContentType() string

func (Frame) CopyToMemory

func (frame Frame) CopyToMemory(keypath state.Keypath, rng *state.Range) (state.Node, error)

func (Frame) DebugPrint

func (frame Frame) DebugPrint(printFn func(inFormat string, args ...interface{}), newlines bool, indentLevel int)

func (Frame) MarshalJSON

func (frame Frame) MarshalJSON() ([]byte, error)

func (Frame) NodeAt

func (frame Frame) NodeAt(keypath state.Keypath, rng *state.Range) state.Node

func (Frame) ParentNodeFor

func (frame Frame) ParentNodeFor(keypath state.Keypath) (state.Node, state.Keypath)

func (Frame) Value

func (frame Frame) Value(keypath state.Keypath, rng *state.Range) (interface{}, bool, error)

type HTTPFrame

type HTTPFrame struct {
	Frame
	// contains filtered or unexported fields
}

func (HTTPFrame) BytesReader

func (frame HTTPFrame) BytesReader(rng *types.Range) (io.ReadCloser, int64, error)

func (HTTPFrame) BytesValue

func (frame HTTPFrame) BytesValue(keypath state.Keypath) ([]byte, bool, error)

func (HTTPFrame) ContentLength

func (frame HTTPFrame) ContentLength() (int64, error)

func (HTTPFrame) MarshalJSON

func (frame HTTPFrame) MarshalJSON() ([]byte, error)

func (HTTPFrame) NodeAt

func (frame HTTPFrame) NodeAt(keypath state.Keypath, rng *state.Range) state.Node

func (HTTPFrame) ParentNodeFor

func (frame HTTPFrame) ParentNodeFor(keypath state.Keypath) (state.Node, state.Keypath)

func (HTTPFrame) StringValue

func (frame HTTPFrame) StringValue(keypath state.Keypath) (string, bool, error)

type HTTPResolver

type HTTPResolver interface {
	Metadata(url url.URL) (exists bool, contentType string, contentLength int64, err error)
	Get(url url.URL, byteRange *types.Range) (_ io.ReadCloser, contentType string, contentLength int64, _ error)
}

type LinkType

type LinkType int
const (
	LinkTypeInvalid LinkType = iota
	LinkTypeBlob
	LinkTypeState
	LinkTypeHTTP
)

func DetermineLinkType

func DetermineLinkType(linkStr string) (LinkType, string)

type Node

type Node interface {
	state.Node
	ContentType() string
	ContentLength() (int64, error)
	BytesReader(rng *types.Range) (io.ReadCloser, int64, error)
}

type Resolver

type Resolver struct {
	// contains filtered or unexported fields
}

func NewResolver

func NewResolver(stateResolver StateResolver, blobResolver BlobResolver, httpResolver HTTPResolver) Resolver

func (Resolver) Resolve

func (r Resolver) Resolve(stateNode state.Node) (resolved state.Node, anyMissing bool, err error)

Given a state.Node, Resolve will recursively resolve all NelSON frames contained therein.

func (Resolver) Seek

func (r Resolver) Seek(node state.Node, keypath state.Keypath) (sought state.Node, exists bool, err error)

Drills down to the provided keypath, resolving links as necessary. If the keypath resolves to a NelSON frame, the frame is returned as a nelson.Frame. Otherwise, a regular state.Node is returned.

type StateResolver

type StateResolver interface {
	StateAtVersion(stateURI string, version *state.Version) (state.Node, error)
}

Jump to

Keyboard shortcuts

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