Documentation
¶
Index ¶
- Variables
- func CompressBytes(data []byte) ([]byte, error)
- func DecompressBytes(data []byte) ([]byte, error)
- func DeserializeBytesToFile(data []byte, save_path string) error
- func DeserializeBytesToFileCompressed(data_comp []byte, save_path string) error
- func DeserializeBytesToGonum(data []byte) (*mat.Dense, error)
- func DeserializeBytesToGonumCompressed(data []byte) (*mat.Dense, error)
- func DeserializeToBinaryBase64(data_encoded string) ([]byte, error)
- func DeserializeToFileBase64(data_encoded string, save_path string) error
- func GonumToNpy(array *mat.Dense, save_path string) error
- func GonumToNumpyBytesIO(array *mat.Dense) ([]byte, error)
- func NpyToGonum(path string) (*mat.Dense, error)
- func NumpyBytesIOtoGonum(data []byte) (*mat.Dense, error)
- func PackContext(path string) ([]byte, error)
- func ResolveCoreData(msg *core.CoreData) ([]byte, error)
- func RunUntilComplete(agt ManagedAgent) error
- func SerializeFileToBytes(path string) ([]byte, error)
- func SerializeFileToBytesCompressed(path string) ([]byte, error)
- func SerializeFromBinaryBase64(data []byte) string
- func SerializeFromFileBase64(filepath string) (string, error)
- func SerializeGonumToBytes(array *mat.Dense) ([]byte, error)
- func SerializeGonumToBytesCompressed(array *mat.Dense) ([]byte, error)
- func UnpackContext(root_dir string, archived_context []byte) error
- type Agent
- type BasicAgent
- func (a *BasicAgent) Done() <-chan struct{}
- func (a *BasicAgent) Goodbye() error
- func (a *BasicAgent) Hello() error
- func (a *BasicAgent) ListenFor(tags []string) <-chan *Post
- func (a *BasicAgent) Log(severity core.Log_Severity, message string) error
- func (a *BasicAgent) Post(metadata []byte, data []byte, tags ...string) error
- func (a *BasicAgent) Reply(posts []*Post, metadata, data []byte, tags ...string) error
- func (a *BasicAgent) SetName(name string)
- func (a *BasicAgent) Start()
- func (a *BasicAgent) Stop()
- func (a *BasicAgent) Trace(post *Post) ([]*Post, error)
- type BlackboardHTTPClient
- func (c *BlackboardHTTPClient) Len() int
- func (c *BlackboardHTTPClient) Read(msg_idx int) (*core.Message, error)
- func (c *BlackboardHTTPClient) Slice(start_idx, end_idx int) ([]*core.Message, error)
- func (c *BlackboardHTTPClient) Trace(msg_idx int, depth int) ([]*core.Message, error)
- func (c *BlackboardHTTPClient) Write(msg *core.Message) error
- type BlackboardTransporter
- type Filter
- type FilterChain
- type ManagedAgent
- type Post
- type TagFilter
- type TagSet
Constants ¶
This section is empty.
Variables ¶
var ( DefaultAgent = &BasicAgent{ done: make(chan struct{}), AgentSpec: &core.AgentSpec{}, BlackboardTransporter: &BlackboardHTTPClient{ Client: &http.Client{}, }, } )
The default agent is an http agent
Functions ¶
func CompressBytes ¶
CompressBytes performs zlib compression on a byte array.
func DecompressBytes ¶
DecompressBytes decompresses an incoming byte array with zlib compression.
func DeserializeBytesToFile ¶
DeserializeBytesToFile writes an incoming byte array to a file.
func DeserializeBytesToFileCompressed ¶
DeserializeBytesToFileCompressed writes an incoming byte array with zlib compression to a file.
func DeserializeBytesToGonum ¶
DeserializeBytesToGonum writes an incoming byte array to a Gonum dense matrix.
func DeserializeBytesToGonumCompressed ¶
DeserializeBytesToGonumCompressed writes an incoming zlib-compressed byte array to a Gonum dense matrix.
func DeserializeToBinaryBase64 ¶
DeserializeToBinary encodes a data string to bytes
func DeserializeToFileBase64 ¶
DeserializeToBinary encodes a data string to a binary file
func GonumToNpy ¶
GonumToNpy converts a Gonum dense matrix to a numpy array npy file with underlying dtype float64.
func GonumToNumpyBytesIO ¶
GonumToNumpyBytesIO converts a Gonum dense matrix to a numpy array with underlying dtype float64 encoded as a byte array.
func NpyToGonum ¶
NpyToGonum converts a .npy file to a Gonum dense matrix.
func NumpyBytesIOtoGonum ¶
NumpyBytesIOtoGonum converts a serialized Numpy array (as read from a BytesIO Python object) to a Gonum dense matrix.
NOTE: The underlying dtype of the numpy array must be float64 to be compatible with Gonum as a dense matrix. Users must keep this in mind if they want Python and Go agents to communicate matrix data directly.
func PackContext ¶
PackContext tars the contents of a directory.
func ResolveCoreData ¶
ResolveCoreData extracts data from a core.CoreData object.
I don't foresee users needing to call this directly, but I also don't see a good reason to keep it private? That being said, it's not intended to be a well-maintained part of the public interface.
func RunUntilComplete ¶
func RunUntilComplete(agt ManagedAgent) error
RunUntilComplete runs the Setup and Loop functions for a ManagedAgent until the agent terminates.
func SerializeFileToBytes ¶
SerializeFileToBytes serializes a specified file to a byte array.
func SerializeFileToBytesCompressed ¶
SerializeFileToBytesCompressed performs zlib compression on a specified file and serializes to a byte array.
func SerializeFromBinaryBase64 ¶
SerializeFromBinary encodes a byte slice with base64 serialization.
func SerializeFromFileBase64 ¶
SerializeFromFile encodes a file with base64 serialization.
func SerializeGonumToBytes ¶
SerializeGonumToBytes wraps mat.Dense.MarshalBinary.
func SerializeGonumToBytesCompressed ¶
SerializeGonumToBytes performs zlib compression on a mat.Dense object and serializes to bytes.
func UnpackContext ¶
Unpacks the contents of an archive into root_dir. root_dir is created if it does not already exist.
Types ¶
type Agent ¶
type Agent interface { Hello() error Goodbye() error Post(metadata []byte, data []byte, tags ...string) error Reply(posts []*Post, metadata []byte, data []byte, tags ...string) error Log(severity core.Log_Severity, message string) error Done() <-chan struct{} }
Agent provides the underlying framework for easy user interaction with core. It automatically starts background processes to communicate with blackboard.
type BasicAgent ¶
type BasicAgent struct { *core.AgentSpec BlackboardTransporter OnNewMessage func(msg *core.Message) StartIdx int // contains filtered or unexported fields }
The BasicAgent type implements Agent but not ManagedAgent. User-defined agents embedding BasicAgent are expected to satisfy the ManagedAgent interface by implementing their own Setup and Loop functions.
func GetDefaultAgent ¶
func GetDefaultAgent(addr string) *BasicAgent
GetDefaultAgent returns a BasicAgent with default initialization.
func (*BasicAgent) Done ¶
func (a *BasicAgent) Done() <-chan struct{}
Done encapsulates the a.done channel for use in select statements.
func (*BasicAgent) Goodbye ¶
func (a *BasicAgent) Goodbye() error
func (*BasicAgent) Hello ¶
func (a *BasicAgent) Hello() error
func (*BasicAgent) ListenFor ¶
func (a *BasicAgent) ListenFor(tags []string) <-chan *Post
ListenFor returns a channel on which users can receive messages matching a provided set of tags.
This channel should function as any other Go channel can/should be used in a Go select statements. The current implementation will surface multiple copies of the same message if it matches multiple filters. If different behavior is desired in the future, implementation can be customized in filter_chain.go.
For deterministic ListenFor behavior, calls must be prior to ANY other API calls that invoke the network. TODO: Add a warning if this occurs
func (*BasicAgent) Log ¶
func (a *BasicAgent) Log(severity core.Log_Severity, message string) error
func (*BasicAgent) Post ¶
func (a *BasicAgent) Post(metadata []byte, data []byte, tags ...string) error
Fewer rules and requirements to send data to the BB
func (*BasicAgent) Reply ¶
func (a *BasicAgent) Reply(posts []*Post, metadata, data []byte, tags ...string) error
Reply populates the ReplyingTo field of an outgoing Post message. It is best used alongside Trace.
func (*BasicAgent) SetName ¶
func (a *BasicAgent) SetName(name string)
SetName sets the name field of the AgentSpec.
func (*BasicAgent) Start ¶
func (a *BasicAgent) Start()
Start may be the most complex function in the whole project. It is the core agent event loop responsible for surfacing tagged posts to awaiting agents.
type BlackboardHTTPClient ¶
BlackboardHTTPClient is the primary agent-facing interface for the Blackboard system, and is the default HTTP-based implementation of the BlackboardTransporter interface. It can be thought of as the "opposite side" of apis.BlackboardHTTPService.
func (*BlackboardHTTPClient) Len ¶
func (c *BlackboardHTTPClient) Len() int
Get the current length of the blackboard. Efficient agent joining requires this.
func (*BlackboardHTTPClient) Read ¶
func (c *BlackboardHTTPClient) Read(msg_idx int) (*core.Message, error)
Read reads a single message. Necessary for tracing.
func (*BlackboardHTTPClient) Slice ¶
func (c *BlackboardHTTPClient) Slice(start_idx, end_idx int) ([]*core.Message, error)
Slice accesses multiple messages on the blackboard. TODO: add the docs for slicing patterns here
type BlackboardTransporter ¶
type BlackboardTransporter interface { Read(msg_idx int) (*core.Message, error) Write(msg *core.Message) error Slice(start_idx, end_idx int) ([]*core.Message, error) Trace(msg_idx int, depth int) ([]*core.Message, error) Len() int // WARN: This should also return an error. I'm not 100% sure why it doesn't... }
This is "duplicated" code (it's just the blackboard interface) but we need to avoid the import cycle. And the function here is different (allowing our agents to utilize a standard interface to different transport code.)
type Filter ¶
Filters and FilterChains process incoming channel messages and surface them based on their specific filter implementation. I think, subconsciously, this ideas is loosely based on firewall filters/rules. NOTE: Might be a better name for this stuff
type FilterChain ¶
type FilterChain struct {
// contains filtered or unexported fields
}
A filter chain provides a convenient way to surface a message accross multiple potential matches. NOTE: FilterChain should probably become an interface sooner rather than later to allow for different implementations of chain behavior.
func NewFilterChain ¶
func NewFilterChain() *FilterChain
NewFilterChain is the constructor for the FilterChain type.
func (*FilterChain) Cleanup ¶
func (f *FilterChain) Cleanup()
Cleanup closes the channel of each filter in the chain.
func (*FilterChain) Insert ¶
func (f *FilterChain) Insert(filt Filter)
Insert wraps append, acting as a set method for the `filters` field.
func (*FilterChain) ListenAndFilter ¶
func (f *FilterChain) ListenAndFilter(done_ch chan struct{}, incoming chan *core.Message)
ListenAndFilter filters an incoming message based on the filters in the chain.
type ManagedAgent ¶
type ManagedAgent interface { Agent Setup() error Loop() (continue_loop bool, err error) SetName(name string) }
ManagedAgent is an interface enforcing the agent-defined Setup and Loop methods and SetName (should be handled by the executable).
Free the agents: keep this interface as narrow as possible
type Post ¶
type Post struct { Tags []string Metadata []byte Data []byte // contains filtered or unexported fields }
Post is a user-facing "Post" type that abstracts the fields of core.Post
func PostFromPostMessage ¶
PostFromPostMessage converts a core.Post message to the user-facing Post type.
Ditto for this one about the public facing interface and all We need to surface the potential http errors to troubleshoot if object store is unavailable.
type TagFilter ¶
type TagFilter struct { TagSet // contains filtered or unexported fields }
A TagFilter filters messages using the TagSet's Match function.
type TagSet ¶
type TagSet map[string]struct{}
TagSet is a type alias for map[string]struct{}, which essentially mimics a set of tag string values.
func NewTagSet ¶
NewTagSet generates a TagSet from a slice. This will have the effect of removing any duplicate tags from the incoming slice.
func (TagSet) Matches ¶
In general, we don't care what "Matches" actually means that much, just that it is definedby this function. However, in THIS implementation, it means the receiver tag set is a subset of the incoming tag set. E.g., if I am ListenFor(TagSet{"lung", "segmentation"}), I would return any message that contains *at least* these two tags. Other implementations may have stronger (or weaker) notions of a match.