예제 #1
0
파일: client.go 프로젝트: petertseng/p2
func (c Client) WatchStatus(ctx context.Context, podUniqueKey types.PodUniqueKey, waitIndex uint64) (<-chan PodStatusResult, error) {
	stream, err := c.client.WatchPodStatus(ctx, &podstore_protos.WatchPodStatusRequest{
		PodUniqueKey:    podUniqueKey.String(),
		StatusNamespace: kp.PreparerPodStatusNamespace.String(),
		WaitIndex:       waitIndex,
	})
	if err != nil {
		return nil, err
	}

	outCh := make(chan PodStatusResult)
	go func() {
		defer close(outCh)
		for {
			status, err := stream.Recv()
			select {
			case <-ctx.Done():
				return
			case outCh <- PodStatusResult{
				PodStatus: status,
				Error:     err,
			}:
			}
		}
	}()
	return outCh, nil
}
예제 #2
0
func (f sqliteFinishService) LastFinishForPodUniqueKey(podUniqueKey types.PodUniqueKey) (FinishOutput, error) {
	row := f.db.QueryRow(`
  SELECT id, date, pod_id, pod_unique_key, launchable_id, entry_point, exit_code, exit_status
  FROM finishes
  WHERE pod_unique_key = ?
  `, podUniqueKey.String())
	return scanRow(row)
}
예제 #3
0
파일: rm.go 프로젝트: petertseng/p2
// Constructs a *P2RM configured to remove a pod identified by a PodUniqueKey (uuid)
func NewUUIDP2RM(client consulutil.ConsulClient, podUniqueKey types.PodUniqueKey, podID types.PodID, labeler labels.ApplicatorWithoutWatches) *P2RM {
	rm := &P2RM{}
	rm.LabelID = podUniqueKey.String()
	rm.PodID = podID
	rm.NodeName = "" // don't need node name to look up a uuid pod
	rm.PodUniqueKey = podUniqueKey
	rm.configureStorage(client, labeler)
	return rm
}
예제 #4
0
func computeRealityIndexPath(key types.PodUniqueKey, node types.NodeName) string {
	return path.Join("reality", node.String(), key.String())
}
예제 #5
0
func computeIntentIndexPath(key types.PodUniqueKey, node types.NodeName) string {
	return path.Join("intent", node.String(), key.String())
}
예제 #6
0
// Given a pod unique key and a node, compute the path to which the main pod
// should be written as well as the secondary index
func computePodPath(key types.PodUniqueKey) string {
	return path.Join(PodTree, key.String())
}