Exemple #1
0
func scanReplica(row *pgx.Rows) (*pgmanager.Replica, error) {
	var start pgx.NullTime
	var id, addr, state, sentLoc, writeLoc, flushLoc, replayLoc, sync pgx.NullString
	var port pgx.NullInt32
	if err := row.Scan(&id, &addr, &port, &start, &state, &sentLoc, &writeLoc, &flushLoc, &replayLoc, &sync); err != nil {
		return nil, err
	}
	return &pgmanager.Replica{
		ID:             id.String,
		Addr:           fmt.Sprintf("%s:%d", addr.String, port.Int32),
		Start:          start.Time,
		State:          state.String,
		Sync:           sync.String == "sync",
		SentLocation:   sentLoc.String,
		WriteLocation:  writeLoc.String,
		FlushLocation:  flushLoc.String,
		ReplayLocation: replayLoc.String,
	}, nil
}
Exemple #2
0
func scanFormations(rows *pgx.Rows) ([]*ct.Formation, error) {
	var formations []*ct.Formation
	for rows.Next() {
		formation, err := scanFormation(rows)
		if err != nil {
			rows.Close()
			return nil, err
		}
		formations = append(formations, formation)
	}
	return formations, rows.Err()
}
Exemple #3
0
func resourceList(rows *pgx.Rows) ([]*ct.Resource, error) {
	var resources []*ct.Resource
	for rows.Next() {
		resource, err := scanResource(rows)
		if err != nil {
			rows.Close()
			return nil, err
		}
		resources = append(resources, resource)
	}
	return resources, rows.Err()
}
Exemple #4
0
func scanArtifacts(rows *pgx.Rows) (interface{}, error) {
	var artifacts []*ct.Artifact
	for rows.Next() {
		artifact, err := scanArtifact(rows)
		if err != nil {
			rows.Close()
			return nil, err
		}
		artifacts = append(artifacts, artifact)
	}
	return artifacts, rows.Err()
}