Go Client


To get started with the Concord Go library, include our header:



The abstract class you must extend our client interface in this way:

type Computation interface {
  // Perform some initialization
  Init(*Context) error

  // Perform some cleanup
  Destroy() error

  // Process incoming records
  ProcessRecords(*Context, *Record) error

  // Proceess a timer callback
  ProcessTimer(*Context, int64, string) error

  // Return a struct defining computation name, istrems, and ostreams
  Metadata() *Metadata

Note that each instance of ctx in the arguments is a context object. In concord, the context object is used to communicate from the client computation to the framework. You can use it to produce records and set timers. The computation context object looks like this:

type Context struct {
    tx    *bolt.ComputationTx
    proxy *proxy

// Retrieve state at `key`
func (c *Context) GetState(key string) ([]byte, error)

// Set some arbitrary state to retrieve later
func (c *Context) SetState(key string, value []byte) error

// Produce a record on `stream` with `key` and `value`
func (c *Context) ProduceRecord(stream, key, value string)

// Trigger a timer named `key` to go off at `time` (ms)
func (c *Context) SetTimer(name string, t time.Time)

Finally, the Metadata object you need to prepare in the metadata method should be initialized as follows:

type Metadata struct {
    // Globaly unique name of the computation
    Name    string

    // List of streams to subscribe to
    Inputs  []*Stream

    // List of streams this computation will produce on
    Outputs []string
  • name: a string identifying the computation
  • istreams: a list of streams to subscribe to.
  • ostreams: a list of streams this computation may produce on.

Directory Structure

Here’s a sample directory layout for a simple Go project using Concord:

my-project/             # project root
  deploy.json           # computation manifest
    computation.go      # computation source
    computation         # computation binary

Computation Manifest

The computation manifest for our sample project would appear as follows:

  // comma-separated list of host:port zookeepers
  // zookeeper base path for concord framework
  // name of the command that should be executed (in a shell environment)
  "executable_name": "computation",
  // files (rooted in your CWD) to include in the package sent to the cluster
  "compress_files": ["build/computation"],
  // globally unique name of the computation (found in your implementation
  // of the metadata function)
  "computation_name": "my-computation"