// RegisterHost is used by the host service to register itself with the leader // and get a stream of new jobs. It is not used by clients. func (c *Client) RegisterHost(host *host.Host, jobs chan *host.Job) Stream { if c := c.local(); c != nil { return c.RegisterHost(host, jobs) } client, err := c.RPCClient() if err != nil { return rpcStream{&rpcplus.Call{Error: err}} } return rpcStream{client.StreamGo("Cluster.RegisterHost", host, jobs)} }
// Register is used by flynn-host to register itself with the leader and get // a stream of new jobs. It is not used by clients. func (c *Client) RegisterHost(host *host.Host, jobs chan *host.Job) *error { if c := c.local(); c != nil { return c.RegisterHost(host, jobs) } client, err := c.RPCClient() if err != nil { return &err } return &client.StreamGo("Cluster.RegisterHost", host, jobs).Error }
// StreamFormations returns a FormationUpdates stream. If since is not nil, only // retrieves formation updates since the specified time. func (c *Client) StreamFormations(since *time.Time) (*FormationUpdates, *error) { if since == nil { s := time.Unix(0, 0) since = &s } dial := c.Dial if dial == nil { dial = net.Dial } ch := make(chan *ct.ExpandedFormation) conn, err := dial("tcp", c.addr) if err != nil { close(ch) return &FormationUpdates{ch, conn}, &err } header := make(http.Header) header.Set("Authorization", "Basic "+base64.StdEncoding.EncodeToString([]byte(":"+c.Key))) client, err := rpcplus.NewHTTPClient(conn, rpcplus.DefaultRPCPath, header) if err != nil { close(ch) return &FormationUpdates{ch, conn}, &err } return &FormationUpdates{ch, conn}, &client.StreamGo("Controller.StreamFormations", since, ch).Error }