CountReplicas counts the number of replicas attached to an instance
( ctx context.Context, crudClient client.Client, kubeInterface kubernetes.Interface, restConfig *rest.Config, pod *corev1.Pod, retryTimeout int, )
| 55 | |
| 56 | // CountReplicas counts the number of replicas attached to an instance |
| 57 | func CountReplicas( |
| 58 | ctx context.Context, |
| 59 | crudClient client.Client, |
| 60 | kubeInterface kubernetes.Interface, |
| 61 | restConfig *rest.Config, |
| 62 | pod *corev1.Pod, |
| 63 | retryTimeout int, |
| 64 | ) (int, error) { |
| 65 | query := "SELECT count(*) FROM pg_catalog.pg_stat_replication" |
| 66 | stdOut, _, err := exec.EventuallyExecQueryInInstancePod( |
| 67 | ctx, crudClient, kubeInterface, restConfig, |
| 68 | exec.PodLocator{ |
| 69 | Namespace: pod.Namespace, |
| 70 | PodName: pod.Name, |
| 71 | }, AppDBName, |
| 72 | query, |
| 73 | retryTimeout, |
| 74 | objects.PollingTime, |
| 75 | ) |
| 76 | if err != nil { |
| 77 | return 0, nil |
| 78 | } |
| 79 | return strconv.Atoi(strings.Trim(stdOut, "\n")) |
| 80 | } |
| 81 | |
| 82 | // GetCurrentTimestamp getting current time stamp from postgres server |
| 83 | func GetCurrentTimestamp( |