server

package
v0.0.0-...-33271ab Latest Latest
Warning

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

Go to latest
Published: Jul 28, 2021 License: Apache-2.0 Imports: 14 Imported by: 1 module, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

View Source
const (
	// actions
	DELETE = "delete"
	RESET  = "reset"
	UPDATE = "update"
	CREATE = "create"
	INFO   = "info"
	// nodes
	BLOCK  = "block"
	GROUP  = "group"
	SOURCE = "source"
	// edges
	LINK       = "link"
	CONNECTION = "connection"
	// attributes
	CHILD      = "child"
	ROUTE      = "route"
	GROUPROUTE = "groupRoute"
	PARAM      = "param"
)

Variables

This section is empty.

Functions

func Logger

func Logger(inner http.Handler, name string) http.Handler

Types

type BlockLedger

type BlockLedger struct {
	Label        string          `json:"label"`
	Type         string          `json:"type"`
	Id           int             `json:"id"`
	Block        *core.Block     `json:"-"`
	Parent       *Group          `json:"-"`
	Composition  int             `json:"composition,omitempty"`
	Inputs       []core.Input    `json:"inputs"`
	Outputs      []core.Output   `json:"outputs"`
	Source       core.SourceType `json:"source"`
	Position     Position        `json:"position"`
	MonitorQuery chan struct{}   `json:"-"`
	MonitorQuit  chan struct{}   `json:"-"`
}

func (*BlockLedger) GetID

func (bl *BlockLedger) GetID() int

func (*BlockLedger) GetParent

func (bl *BlockLedger) GetParent() *Group

func (*BlockLedger) SetParent

func (bl *BlockLedger) SetParent(group *Group)

type ConnectionLedger

type ConnectionLedger struct {
	Source ConnectionNode `json:"from"`
	Target ConnectionNode `json:"to"`
	Id     int            `json:"id"`
}

type ConnectionNode

type ConnectionNode struct {
	Id    int `json:"id"`
	Route int `json:"route"`
}

type Error

type Error struct {
	Text string `json:"text"`
}

type Group

type Group struct {
	Id           int                `json:"id"`
	Label        string             `json:"label"`
	Children     []int              `json:"children"`
	Parent       *Group             `json:"-"`
	Position     Position           `json:"position"`
	HiddenRoutes HiddenRoutesLedger `json:"hiddenRoutes"`
}

func (*Group) GetID

func (g *Group) GetID() int

func (*Group) GetParent

func (g *Group) GetParent() *Group

func (*Group) SetParent

func (g *Group) SetParent(group *Group)

type GroupRoute

type GroupRoute struct {
	RouteId   string `json:"routeId"`
	IsVisible bool   `json:"isVisible"`
}

type HiddenRoutesLedger

type HiddenRoutesLedger map[string]struct{}

func (HiddenRoutesLedger) MarshalJSON

func (h HiddenRoutesLedger) MarshalJSON() ([]byte, error)

func (HiddenRoutesLedger) UnmarshalJSON

func (h HiddenRoutesLedger) UnmarshalJSON(data []byte) error

type LibraryEntry

type LibraryEntry struct {
	Name     string          `json:"name"`
	Source   core.SourceType `json:"source"`
	Category []string        `json:"category"`
}

type LinkLedger

type LinkLedger struct {
	Source struct {
		Id int `json:"id"`
	} `json:"source"` // the source id
	Block struct {
		Id int `json:"id"`
	} `json:"block"` // the block id
	Id int `json:"id"` // link id
}

type Node

type Node interface {
	GetID() int
	GetParent() *Group
	SetParent(*Group)
}

type Pattern

type Pattern struct {
	Label       string             `json:"label"`
	Blocks      []BlockLedger      `json:"blocks"`
	Connections []ConnectionLedger `json:"connections"`
	Groups      []Group            `json:"groups"`
	Sources     []SourceLedger     `json:"sources"`
	Links       []LinkLedger       `json:"links"`
}

type Position

type Position struct {
	X float64 `json:"x"`
	Y float64 `json:"y"`
}

type ProtoBlock

type ProtoBlock struct {
	Label    string   `json:"label"`
	Parent   int      `json:"parent"`
	Type     string   `json:"type"`
	Position Position `json:"position"`
}

type ProtoConnection

type ProtoConnection struct {
	Source ConnectionNode `json:"from"`
	Target ConnectionNode `json:"to"`
}

type ProtoGroup

type ProtoGroup struct {
	Group    int      `json:"parent"`
	Children []int    `json:"children"`
	Label    string   `json:"label"`
	Position Position `json:"position"`
}
type ProtoLink struct {
	Source struct {
		Id int `json:"id"`
	} `json:"source"` // the source id
	Block struct {
		Id int `json:"id"`
	} `json:"block"` // the block id
}

type ProtoSource

type ProtoSource struct {
	Label      string            `json:"label"`
	Type       string            `json:"type"`
	Position   Position          `json:"position"`
	Parent     int               `json:"parent"`
	Parameters map[string]string `json:"params"`
}

type Server

type Server struct {
	sync.Mutex
	// contains filtered or unexported fields
}

The Server maintains a set of handlers that coordinate the creation of Nodes

func NewServer

func NewServer(settings Settings) *Server

NewServer starts a new Server. This object is immediately up and running.

func (*Server) AddChildToGroup

func (s *Server) AddChildToGroup(id int, n Node) error

func (*Server) BlockCreateHandler

func (s *Server) BlockCreateHandler(w http.ResponseWriter, r *http.Request)

BlockCreateHandler CreateBlockHandler responds to a POST request to instantiate a new block and add it to the Server.

func (*Server) BlockDeleteHandler

func (s *Server) BlockDeleteHandler(w http.ResponseWriter, r *http.Request)

func (*Server) BlockHandler

func (s *Server) BlockHandler(w http.ResponseWriter, r *http.Request)

func (*Server) BlockIndexHandler

func (s *Server) BlockIndexHandler(w http.ResponseWriter, r *http.Request)

func (*Server) BlockLibraryHandler

func (s *Server) BlockLibraryHandler(w http.ResponseWriter, r *http.Request)

func (*Server) BlockModifyNameHandler

func (s *Server) BlockModifyNameHandler(w http.ResponseWriter, r *http.Request)

func (*Server) BlockModifyPositionHandler

func (s *Server) BlockModifyPositionHandler(w http.ResponseWriter, r *http.Request)

func (*Server) BlockModifyRouteHandler

func (s *Server) BlockModifyRouteHandler(w http.ResponseWriter, r *http.Request)

func (*Server) ConnectionCreateHandler

func (s *Server) ConnectionCreateHandler(w http.ResponseWriter, r *http.Request)

ConnectionCreateHandler CreateConnectionHandler responds to a POST request to instantiate a new connection

func (*Server) ConnectionDeleteHandler

func (s *Server) ConnectionDeleteHandler(w http.ResponseWriter, r *http.Request)

func (*Server) ConnectionHandler

func (s *Server) ConnectionHandler(w http.ResponseWriter, r *http.Request)

ConnectionHandler returns a description of the connection

func (*Server) ConnectionIndexHandler

func (s *Server) ConnectionIndexHandler(w http.ResponseWriter, r *http.Request)

func (*Server) ConnectionModifyCoordinates

func (s *Server) ConnectionModifyCoordinates(w http.ResponseWriter, r *http.Request)

func (*Server) CreateBlock

func (s *Server) CreateBlock(p ProtoBlock) (*BlockLedger, error)

func (*Server) CreateConnection

func (s *Server) CreateConnection(newConn ProtoConnection) (*ConnectionLedger, error)

func (*Server) CreateGroup

func (s *Server) CreateGroup(g ProtoGroup) (*Group, error)
func (s *Server) CreateLink(l ProtoLink) (*LinkLedger, error)

func (*Server) CreateSource

func (s *Server) CreateSource(p ProtoSource) (*SourceLedger, error)

func (*Server) DeleteBlock

func (s *Server) DeleteBlock(id int) error

func (*Server) DeleteConnection

func (s *Server) DeleteConnection(id int) error

func (*Server) DeleteGroup

func (s *Server) DeleteGroup(id int) error
func (s *Server) DeleteLink(id int) error

func (*Server) DeleteSource

func (s *Server) DeleteSource(id int) error

func (*Server) DetachChild

func (s *Server) DetachChild(g Node) error

func (*Server) Export

func (s *Server) Export(id int) (*Pattern, error)

func (*Server) ExportGroup

func (s *Server) ExportGroup(id int) (*Pattern, error)

func (*Server) GetNextID

func (s *Server) GetNextID() int

GetNextID returns the next ID to be used for a new group or a new block

func (*Server) GetSourceValue

func (s *Server) GetSourceValue(id int) ([]byte, error)

func (*Server) GroupCreateHandler

func (s *Server) GroupCreateHandler(w http.ResponseWriter, r *http.Request)

GroupCreateHandler CreateGroupHandler responds to a POST request to instantiate a new group and add it to the Server. Moves all the specified children out of the parent's group and into the new group.

func (*Server) GroupDeleteHandler

func (s *Server) GroupDeleteHandler(w http.ResponseWriter, r *http.Request)

func (*Server) GroupExportGistHandler

func (s *Server) GroupExportGistHandler(w http.ResponseWriter, r *http.Request)

func (*Server) GroupExportHandler

func (s *Server) GroupExportHandler(w http.ResponseWriter, r *http.Request)

func (*Server) GroupHandler

func (s *Server) GroupHandler(w http.ResponseWriter, r *http.Request)

GroupHandler returns a description of the group - its id and children

func (*Server) GroupImportGistHandler

func (s *Server) GroupImportGistHandler(w http.ResponseWriter, r *http.Request)

func (*Server) GroupImportHandler

func (s *Server) GroupImportHandler(w http.ResponseWriter, r *http.Request)

func (*Server) GroupIndexHandler

func (s *Server) GroupIndexHandler(w http.ResponseWriter, r *http.Request)

func (*Server) GroupModifyAllChildrenHandler

func (s *Server) GroupModifyAllChildrenHandler(w http.ResponseWriter, r *http.Request)

func (*Server) GroupModifyChildHandler

func (s *Server) GroupModifyChildHandler(w http.ResponseWriter, r *http.Request)

func (*Server) GroupModifyLabelHandler

func (s *Server) GroupModifyLabelHandler(w http.ResponseWriter, r *http.Request)

func (*Server) GroupPositionHandler

func (s *Server) GroupPositionHandler(w http.ResponseWriter, r *http.Request)

func (*Server) GroupSetRouteVisibilityHandler

func (s *Server) GroupSetRouteVisibilityHandler(w http.ResponseWriter, r *http.Request)

func (*Server) ImportGroup

func (s *Server) ImportGroup(id int, p Pattern) ([]int, error)

func (*Server) LinkCreateHandler

func (s *Server) LinkCreateHandler(w http.ResponseWriter, r *http.Request)

func (*Server) LinkDeleteHandler

func (s *Server) LinkDeleteHandler(w http.ResponseWriter, r *http.Request)

func (*Server) LinkIndexHandler

func (s *Server) LinkIndexHandler(w http.ResponseWriter, r *http.Request)

func (*Server) ListBlocks

func (s *Server) ListBlocks() []BlockLedger

func (*Server) ListConnections

func (s *Server) ListConnections() []ConnectionLedger

func (*Server) ListGroups

func (s *Server) ListGroups() []Group

func (*Server) ListSources

func (s *Server) ListSources() []SourceLedger

func (*Server) ModifyBlockRoute

func (s *Server) ModifyBlockRoute(id int, route int, v *core.InputValue) error

func (*Server) MonitorMux

func (s *Server) MonitorMux(id int, c chan core.MonitorMessage, query chan struct{}, quit chan struct{})

func (*Server) NewRouter

func (s *Server) NewRouter() *mux.Router

func (*Server) ResetGraph

func (s *Server) ResetGraph(conn *ConnectionLedger)

ResetGraph stops/resets/starts the entire connected subgraph related to connection Conn. It is a general approach that probably touches a lot more blocks than it needs to.

TODO: This function should be replaced with language-level features that allow insight into stuck messages OR run in a more precise fashion (detecting branching/merging of streams).

func (*Server) SetSourceValue

func (s *Server) SetSourceValue(id int, body []byte) error

func (*Server) SourceCreateHandler

func (s *Server) SourceCreateHandler(w http.ResponseWriter, r *http.Request)

func (*Server) SourceDeleteHandler

func (s *Server) SourceDeleteHandler(w http.ResponseWriter, r *http.Request)

func (*Server) SourceGetValueHandler

func (s *Server) SourceGetValueHandler(w http.ResponseWriter, r *http.Request)

func (*Server) SourceHandler

func (s *Server) SourceHandler(w http.ResponseWriter, r *http.Request)

func (*Server) SourceIndexHandler

func (s *Server) SourceIndexHandler(w http.ResponseWriter, r *http.Request)

func (*Server) SourceLibraryHandler

func (s *Server) SourceLibraryHandler(w http.ResponseWriter, r *http.Request)

func (*Server) SourceModifyNameHandler

func (s *Server) SourceModifyNameHandler(w http.ResponseWriter, r *http.Request)

func (*Server) SourceModifyPositionHandler

func (s *Server) SourceModifyPositionHandler(w http.ResponseWriter, r *http.Request)

func (*Server) SourceSetValueHandler

func (s *Server) SourceSetValueHandler(w http.ResponseWriter, r *http.Request)

func (*Server) UpdateSocketHandler

func (s *Server) UpdateSocketHandler(w http.ResponseWriter, r *http.Request)

type Settings

type Settings struct {
	GithubUserToken string
}

user-session specific settings

func NewSettings

func NewSettings() Settings

NewSettings returns the default settings object

type SourceLedger

type SourceLedger struct {
	Label      string              `json:"label"`
	Type       string              `json:"type"`
	Id         int                 `json:"id"`
	Source     core.Source         `json:"-"`
	Parent     *Group              `json:"-"`
	Token      suture.ServiceToken `json:"-"`
	Position   Position            `json:"position"`
	Parameters []map[string]string `json:"params"`
}

func (*SourceLedger) GetID

func (sl *SourceLedger) GetID() int

func (*SourceLedger) GetParent

func (sl *SourceLedger) GetParent() *Group

func (*SourceLedger) SetParent

func (sl *SourceLedger) SetParent(group *Group)

type Update

type Update struct {
	Action string      `json:"action"`
	Type   string      `json:"type"`
	Data   interface{} `json:"data"`
}

Jump to

Keyboard shortcuts

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