Ejemplo n.º 1
0
func (a *rethinkAPIServer) insertMessage(table Table, message proto.Message) error {
	data, err := marshaller.MarshalToString(message)
	if err != nil {
		return err
	}
	_, err = a.getTerm(table).Insert(gorethink.JSON(data)).RunWrite(a.session)
	return err
}
Ejemplo n.º 2
0
func (c *rethinkClient) CreatePipelineRun(pipelineRun *pps.PipelineRun) error {
	data, err := marshaller.MarshalToString(pipelineRun)
	if err != nil {
		return err
	}
	_, err = c.pipelineRuns.Insert(gorethink.JSON(data)).RunWrite(c.session)
	return err
}
Ejemplo n.º 3
0
func (c *rethinkClient) addMessage(term gorethink.Term, message proto.Message) error {
	data, err := marshaller.MarshalToString(message)
	if err != nil {
		return err
	}
	_, err = term.Insert(gorethink.JSON(data)).RunWrite(c.session)
	return err
}
Ejemplo n.º 4
0
func (c *rethinkClient) CreatePfsCommitMapping(pfsCommitMapping *pps.PfsCommitMapping) error {
	data, err := marshaller.MarshalToString(pfsCommitMapping)
	if err != nil {
		return err
	}
	if _, err := c.pfsCommitMappings.Insert(gorethink.JSON(data)).RunWrite(c.session); err != nil {
		return err
	}
	return nil
}
Ejemplo n.º 5
0
func (c *rethinkClient) CreatePipelineRunStatus(id string, statusType pps.PipelineRunStatusType) error {
	runStatus := &pps.PipelineRunStatus{
		PipelineRunId:         id,
		PipelineRunStatusType: statusType,
		Timestamp:             prototime.TimeToTimestamp(c.timer.Now()),
	}
	data, err := marshaller.MarshalToString(runStatus)
	if err != nil {
		return err
	}
	_, err = c.pipelineRunStatuses.Insert(gorethink.JSON(data)).RunWrite(c.session)
	return err
}
Ejemplo n.º 6
0
func (c *rethinkClient) CreatePipelineRunLogs(pipelineLogs ...*pps.PipelineRunLog) error {
	var pipelineLogTerms []gorethink.Term
	for _, pipelineLog := range pipelineLogs {
		data, err := marshaller.MarshalToString(pipelineLog)
		if err != nil {
			return err
		}
		pipelineLogTerms = append(pipelineLogTerms, gorethink.JSON(data))
	}
	if _, err := c.pipelineLogs.Insert(pipelineLogTerms).RunWrite(c.session); err != nil {
		return err
	}
	return nil
}
Ejemplo n.º 7
0
func (a *ArchiveWorker) HandleMessage(m *nsq.Message) error {
	resp, err := gorethink.Table(a.table).Insert(archivePayload{
		Timestamp: gorethink.Now(),
		Payload:   gorethink.JSON(string(m.Body)),
	}).RunWrite(a.session)
	if err != nil {
		return err
	}
	// if a producer is set then we are to push the resulting data for each of the webhhooks
	// onto a new queue.
	if a.producer != nil {
		return a.pushPayload(resp.GeneratedKeys[0])
	}
	return nil
}
Ejemplo n.º 8
0
func (c *rethinkClient) AddPipelineRunContainers(containers ...*pps.PipelineRunContainer) error {
	var pipelineContainers []gorethink.Term
	for _, pipelineContainer := range containers {
		data, err := marshaller.MarshalToString(pipelineContainer)
		if err != nil {
			return err
		}
		pipelineContainers = append(pipelineContainers, gorethink.JSON(data))
	}
	if _, err := c.containers.
		Insert(pipelineContainers).
		RunWrite(c.session); err != nil {
		return err
	}
	return nil
}