func (d *database) getPrimaryWorkers() ([]*Worker, error) {
	var workers []*Worker
	err := d.db.Select(&workers,
		"SELECT "+workerColumns+" from pg_dist_node where noderole = 'primary';")
	return workers, err
}
getPrimaryWorkers returns all the primary workers for a database.
package core
import (
	"database/sql"
	"errors"
	"time"
)
var ErrDBNotFound = errors.New("no such database found")
const nodeColumns = "formationid,nodeid,groupid,nodename,nodehost,nodeport,sysidentifier," +
	"goalstate,reportedstate,reportedpgisrunning,reportedrepstate,reporttime,reportedlsn," +
	"reportedtli,walreporttime,health,healthchecktime,statechangetime,candidatepriority," +
	"replicationquorum,nodecluster"
type Node struct {
	FormationID         string    `db:"formationid" json:"formation_id"`
	ID                  int       `db:"nodeid" json:"id"`
	GroupID             int       `db:"groupid" json:"group_id"`
	Name                string    `db:"nodename" json:"name"`
	Host                string    `db:"nodehost" json:"host"`
	Port                int       `db:"nodeport" json:"port"`
	SysIdentifier       string    `db:"sysidentifier" json:"sys_identifier"`
	GoalState           string    `db:"goalstate" json:"goal_state"`
	ReportedState       string    `db:"reportedstate" json:"reported_state"`
	ReportedPGIsRunning bool      `db:"reportedpgisrunning" json:"reported_pg_is_running"`
	ReportedRepState    string    `db:"reportedrepstate" json:"reported_rep_state"`
	ReportTime          time.Time `db:"reporttime" json:"report_time"`
	ReportedLSN         string    `db:"reportedlsn" json:"reported_lsn"`
	ReportedTLI         int       `db:"reportedtli" json:"reported_tli"`
	WALReportTime       time.Time `db:"walreporttime" json:"wal_report_time"`
	Health              int       `db:"health" json:"health"`
	HealthCheckTime     time.Time `db:"healthchecktime" json:"health_check_time"`
	StateChangeTime     time.Time `db:"statechangetime" json:"state_change_time"`
	CandidatePriority   int       `db:"candidatepriority" json:"candidate_priority"`
	ReplicationQuorum   bool      `db:"replicationquorum" json:"replication_quorum"`
	NodeCluster         string    `db:"nodecluster" json:"node_cluster"`
	IsCoordinator       bool      `db:"-" json:"-"`
}
const workerColumns = "nodeid,groupid,nodename,nodeport,noderack,hasmetadata,isactive,noderole," +
	"nodecluster,metadatasynced,shouldhaveshards"
type Worker struct {
	ID               int      `db:"nodeid" json:"id"`
	GroupID          int      `db:"groupid" json:"group_id"`
	Host             string   `db:"nodename" json:"host"`
	Port             int      `db:"nodeport" json:"port"`
	Rack             string   `db:"noderack" json:"rack"`
	HasMetaData      NullBool `db:"hasmetadata" json:"has_meta_data"`
	Active           bool     `db:"isactive" json:"active"`
	Role             string   `db:"noderole" json:"role"`
	Cluster          string   `db:"nodecluster" json:"cluster"`
	MetaDataSynced   NullBool `db:"metadatasynced" json:"meta_data_synced"`
	ShouldHaveShards bool     `db:"shouldhaveshards" json:"should_have_shards"`
}
const coordinatorColumns = "primary_node_id,primary_name,primary_host,primary_port"
type Coordinator struct {
	PrimaryNodeID int    `db:"primary_node_id" json:"primary_node_id"`
	Name          string `db:"primary_name" json:"name"`
	Host          string `db:"primary_host" json:"host"`
	Port          int    `db:"primary_port" json:"port"`
}
func GetNodes() ([]*Node, error) {
	var nodes []*Node
	err := monitorDB.Select(&nodes, "select "+nodeColumns+" from pgautofailover.node")
	return nodes, err
}
func GetPrimaryCoordinator(dbname string) (*Coordinator, error) {
	var db *database
	if db = findDatabase(dbname); db == nil {
		return nil, ErrDBNotFound
	}
	return db.getCoordinator()
}
func GetPrimaryWorkers(dbname string) ([]*Worker, error) {
	var db *database
	var workers []*Worker
	if db = findDatabase(dbname); db == nil {
		return workers, nil
	}
	return db.getPrimaryWorkers()
}
func GetCoordinators(dbname string) ([]*Node, error) {
	var coordinators []*Node
	var db *database
	if db = findDatabase(dbname); db == nil {
		return coordinators, nil
	}
	err := monitorDB.Select(
		&coordinators,
		"select "+nodeColumns+" from pgautofailover.node where formationid = $1;",
		db.formation,
	)
	return coordinators, err
}