graph

package
v0.0.0-...-05fba6c Latest Latest
Warning

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

Go to latest
Published: Apr 29, 2022 License: MIT Imports: 16 Imported by: 0

Documentation

Index

Constants

View Source
const (
	KeepAliveTimeout = 30 * time.Second
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Block

type Block struct {
	ID          string                `json:"id,omitempty"`
	CreatedAt   *time.Time            `json:"created_at"`
	Content     string                `json:"content"`
	ContentType *executor.ContentType `json:"content_type"`
	MD5         string                `json:"md5"`

	LastExecutedAt    *time.Time `json:"last_executed_at,omitempty"`
	LastExecutedBy    string     `json:"last_executed_by,omitempty"`
	LastExitStatus    string     `json:"last_exit_status,omitempty"`
	LastExecutionInfo string     `json:"last_execution_info,omitempty"`
}

func (*Block) IsCode

func (block *Block) IsCode() bool

type Error

type Error struct {
	Context string
	Err     error
}

func (Error) Error

func (ge Error) Error() string

func (Error) Unwrap

func (ge Error) Unwrap() error

type ErrorResponse

type ErrorResponse struct {
	OccurredAt time.Time `json:"occurred_at"`
	Status     int       `json:"status"`
	Error      string    `json:"error"`
	Message    string    `json:"message"`
	Path       string    `json:"path"`
}

type HttpError

type HttpError struct {
	Err      error
	HTTPCode int
}

HttpError is the kind of error raised in graph processing

func (HttpError) Error

func (ge HttpError) Error() string

func (HttpError) Unwrap

func (ge HttpError) Unwrap() error

type Kind

type Kind string
const (
	Unknown       Kind = "Unknown"
	Command       Kind = "Command"
	Slurp         Kind = "Slurp"
	AsciiCast     Kind = "AsciiCast"
	TextSelect    Kind = "TextSelect"
	ClipboardCopy Kind = "ClipboardCopy"
	Text          Kind = "Text"
)

type Metadata

type Metadata struct {
	SourceTitle string `json:"source_title"`
	SourceURI   string `json:"source_uri"`
	Agent       string `json:"Agent"`
}

func NewMetadata

func NewMetadata(agent, version string) *Metadata

type Node

type Node struct {
	ID             string     `json:"id,omitempty"`
	CreatedAt      *time.Time `json:"created_at"`
	OccurredAt     *time.Time `json:"occurred_at,omitempty"`
	DeletedAt      *time.Time `json:"deleted_at,omitempty"`
	Kind           Kind       `json:"kind"`
	Metadata       Metadata   `json:"metadata"`
	Title          string     `json:"title,omitempty"`
	Markdown       string     `json:"markdown,omitempty"`
	View           string     `json:"view"`
	Blocks         []*Block   `json:"blocks,omitempty"`
	Children       string     `json:"children,omitempty"`
	IsShared       bool       `json:"is_shared"`
	LastExecutedAt *time.Time `json:"last_executed_at"`
	LastExecutedBy string     `json:"last_executed_by"`

	// ChildNodes is the actual reference to the node(s)
	// Note: currently, this relation is not persisted in the remote store
	//       so skip this from json encoding..
	ChildNodes []*Node `json:"-"`
}

func NewNode

func NewNode(kind Kind, title, content, contentType string, metadata Metadata) (*Node, error)

func NewNodeFromBlocks

func NewNodeFromBlocks(kind Kind, blocks []*Block, metadata Metadata) (*Node, error)

func (*Node) GetBlock

func (n *Node) GetBlock(blockID string) (*Block, bool)

func (*Node) GetChildIDs

func (n *Node) GetChildIDs() []string

func (*Node) HasBlocks

func (n *Node) HasBlocks() bool

func (*Node) HasChildren

func (n *Node) HasChildren() bool

func (*Node) LoadChildNodes

func (n *Node) LoadChildNodes(store Store, force bool) error

func (Node) String

func (n Node) String() string

type Store

type Store interface {
	// ExtractID parses the input string to
	// extract the ID understood by the store
	ExtractID(string) (string, error)

	// GetNodes returns the most recent n entries
	GetNodes(limit int, kind Kind) ([]Node, error)

	// GetNode returns the Node associated with this id
	GetNode(id string) (*Node, error)

	// AddNode adds a new node to this store
	AddNode(*Node) (*Node, error)

	// SearchNodes searches for nodes for provided query
	SearchNodes(query string, limit int, kind Kind) ([]Node, error)

	// GetChildren returns the children nodes of the parent node with this id
	GetChildren(parentID string) ([]Node, error)

	// UpdateNode updates the content of an existing node
	UpdateNode(node *Node) error

	// UpdateNodeBlock updates the block of an existing node at the server
	UpdateNodeBlock(node *Node, block *Block) error

	// UpdateNodeBlockExecution updates the block's execution info
	UpdateNodeBlockExecution(node *Node, block *Block) error
}

func NewStore

func NewStore(configEntry *config.Entry, metadata *Metadata) Store

type UpdateBlockExecutionReq

type UpdateBlockExecutionReq struct {
	ExecutedAt *time.Time `json:"executed_at"`
	ExecutedBy string     `json:"executed_by"`
	ExitStatus string     `json:"exit_status"`
	Info       string     `json:"info"`
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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