Debian Codegraph @

api/redis/v1/redis_utils.go

raw symbols SCIP
1 package redisscip-go gomod github.com/scaleway/scaleway-sdk-go . `github.com/scaleway/scaleway-sdk-go/api/redis/v1`/
2
3 import (
4 "timescip-go gomod github.com/golang/go/src go1.17 time/"
5
6 "github.com/scaleway/scaleway-sdk-go/errorsscip-go gomod github.com/scaleway/scaleway-sdk-go . `github.com/scaleway/scaleway-sdk-go/errors`/"
7 "github.com/scaleway/scaleway-sdk-go/internal/asyncscip-go gomod github.com/scaleway/scaleway-sdk-go . `github.com/scaleway/scaleway-sdk-go/internal/async`/"
8 "github.com/scaleway/scaleway-sdk-go/scwscip-go gomod github.com/scaleway/scaleway-sdk-go . `github.com/scaleway/scaleway-sdk-go/scw`/"
9 )
10
11 const (
12 defaultRetryIntervalscip-go gomod github.com/scaleway/scaleway-sdk-go . `github.com/scaleway/scaleway-sdk-go/api/redis/v1`/defaultRetryInterval. = 15 * timescip-go gomod github.com/golang/go/src go1.17 time/.Secondscip-go gomod github.com/golang/go/src go1.17 time/Second.
13 defaultTimeoutscip-go gomod github.com/scaleway/scaleway-sdk-go . `github.com/scaleway/scaleway-sdk-go/api/redis/v1`/defaultTimeout. = 15 * timescip-go gomod github.com/golang/go/src go1.17 time/.Minutescip-go gomod github.com/golang/go/src go1.17 time/Minute.
14 )
15
16 // WaitForClusterRequest is used by WaitForCluster method.
17 type WaitForClusterRequestscip-go gomod github.com/scaleway/scaleway-sdk-go . `github.com/scaleway/scaleway-sdk-go/api/redis/v1`/WaitForClusterRequest# struct {
18 ClusterIDscip-go gomod github.com/scaleway/scaleway-sdk-go . `github.com/scaleway/scaleway-sdk-go/api/redis/v1`/WaitForClusterRequest#ClusterID. string
19 Zonescip-go gomod github.com/scaleway/scaleway-sdk-go . `github.com/scaleway/scaleway-sdk-go/api/redis/v1`/WaitForClusterRequest#Zone. scwscip-go gomod github.com/scaleway/scaleway-sdk-go . `github.com/scaleway/scaleway-sdk-go/scw`/.Zonescip-go gomod github.com/scaleway/scaleway-sdk-go . `github.com/scaleway/scaleway-sdk-go/scw`/Zone#
20 Timeoutscip-go gomod github.com/scaleway/scaleway-sdk-go . `github.com/scaleway/scaleway-sdk-go/api/redis/v1`/WaitForClusterRequest#Timeout. *timescip-go gomod github.com/golang/go/src go1.17 time/.Durationscip-go gomod github.com/golang/go/src go1.17 time/Duration#
21 RetryIntervalscip-go gomod github.com/scaleway/scaleway-sdk-go . `github.com/scaleway/scaleway-sdk-go/api/redis/v1`/WaitForClusterRequest#RetryInterval. *timescip-go gomod github.com/golang/go/src go1.17 time/.Durationscip-go gomod github.com/golang/go/src go1.17 time/Duration#
22 }
23
24 // WaitForCluster waits for the cluster to be in a "terminal state" before returning.
25 // This function can be used to wait for a cluster to be ready for example.
26 func (s *APIscip-go gomod github.com/scaleway/scaleway-sdk-go . `github.com/scaleway/scaleway-sdk-go/api/redis/v1`/API#) WaitForClusterscip-go gomod github.com/scaleway/scaleway-sdk-go . `github.com/scaleway/scaleway-sdk-go/api/redis/v1`/API#WaitForCluster().(req *WaitForClusterRequestscip-go gomod github.com/scaleway/scaleway-sdk-go . `github.com/scaleway/scaleway-sdk-go/api/redis/v1`/WaitForClusterRequest#, opts ...scwscip-go gomod github.com/scaleway/scaleway-sdk-go . `github.com/scaleway/scaleway-sdk-go/scw`/.RequestOptionscip-go gomod github.com/scaleway/scaleway-sdk-go . `github.com/scaleway/scaleway-sdk-go/scw`/RequestOption#) (*Clusterscip-go gomod github.com/scaleway/scaleway-sdk-go . `github.com/scaleway/scaleway-sdk-go/api/redis/v1`/Cluster#, error) {
27 timeout := defaultTimeoutscip-go gomod github.com/scaleway/scaleway-sdk-go . `github.com/scaleway/scaleway-sdk-go/api/redis/v1`/defaultTimeout.
28 if req.Timeoutscip-go gomod github.com/scaleway/scaleway-sdk-go . `github.com/scaleway/scaleway-sdk-go/api/redis/v1`/WaitForClusterRequest#Timeout. != nil {
29 timeout = *req.Timeoutscip-go gomod github.com/scaleway/scaleway-sdk-go . `github.com/scaleway/scaleway-sdk-go/api/redis/v1`/WaitForClusterRequest#Timeout.
30 }
31 retryInterval := defaultRetryIntervalscip-go gomod github.com/scaleway/scaleway-sdk-go . `github.com/scaleway/scaleway-sdk-go/api/redis/v1`/defaultRetryInterval.
32 if req.RetryIntervalscip-go gomod github.com/scaleway/scaleway-sdk-go . `github.com/scaleway/scaleway-sdk-go/api/redis/v1`/WaitForClusterRequest#RetryInterval. != nil {
33 retryInterval = *req.RetryIntervalscip-go gomod github.com/scaleway/scaleway-sdk-go . `github.com/scaleway/scaleway-sdk-go/api/redis/v1`/WaitForClusterRequest#RetryInterval.
34 }
35
36 terminalStatus := map[ClusterStatusscip-go gomod github.com/scaleway/scaleway-sdk-go . `github.com/scaleway/scaleway-sdk-go/api/redis/v1`/ClusterStatus#]struct{}{
37 ClusterStatusReadyscip-go gomod github.com/scaleway/scaleway-sdk-go . `github.com/scaleway/scaleway-sdk-go/api/redis/v1`/ClusterStatusReady.: {},
38 ClusterStatusLockedscip-go gomod github.com/scaleway/scaleway-sdk-go . `github.com/scaleway/scaleway-sdk-go/api/redis/v1`/ClusterStatusLocked.: {},
39 ClusterStatusErrorscip-go gomod github.com/scaleway/scaleway-sdk-go . `github.com/scaleway/scaleway-sdk-go/api/redis/v1`/ClusterStatusError.: {},
40 ClusterStatusSuspendedscip-go gomod github.com/scaleway/scaleway-sdk-go . `github.com/scaleway/scaleway-sdk-go/api/redis/v1`/ClusterStatusSuspended.: {},
41 }
42
43 cluster, err := asyncscip-go gomod github.com/scaleway/scaleway-sdk-go . `github.com/scaleway/scaleway-sdk-go/internal/async`/.WaitSyncscip-go gomod github.com/scaleway/scaleway-sdk-go . `github.com/scaleway/scaleway-sdk-go/internal/async`/WaitSync().(&asyncscip-go gomod github.com/scaleway/scaleway-sdk-go . `github.com/scaleway/scaleway-sdk-go/internal/async`/.WaitSyncConfigscip-go gomod github.com/scaleway/scaleway-sdk-go . `github.com/scaleway/scaleway-sdk-go/internal/async`/WaitSyncConfig#{
44 Getscip-go gomod github.com/scaleway/scaleway-sdk-go . `github.com/scaleway/scaleway-sdk-go/internal/async`/WaitSyncConfig#Get.: func() (interface{}, bool, error) {
45 res, err := s.GetClusterscip-go gomod github.com/scaleway/scaleway-sdk-go . `github.com/scaleway/scaleway-sdk-go/api/redis/v1`/API#GetCluster().(&GetClusterRequestscip-go gomod github.com/scaleway/scaleway-sdk-go . `github.com/scaleway/scaleway-sdk-go/api/redis/v1`/GetClusterRequest#{
46 Zonescip-go gomod github.com/scaleway/scaleway-sdk-go . `github.com/scaleway/scaleway-sdk-go/api/redis/v1`/GetClusterRequest#Zone.: req.Zonescip-go gomod github.com/scaleway/scaleway-sdk-go . `github.com/scaleway/scaleway-sdk-go/api/redis/v1`/WaitForClusterRequest#Zone.,
47 ClusterIDscip-go gomod github.com/scaleway/scaleway-sdk-go . `github.com/scaleway/scaleway-sdk-go/api/redis/v1`/GetClusterRequest#ClusterID.: req.ClusterIDscip-go gomod github.com/scaleway/scaleway-sdk-go . `github.com/scaleway/scaleway-sdk-go/api/redis/v1`/WaitForClusterRequest#ClusterID.,
48 }, opts...)
49 if err != nil {
50 return nil, false, err
51 }
52
53 _, isTerminal := terminalStatus[res.Statusscip-go gomod github.com/scaleway/scaleway-sdk-go . `github.com/scaleway/scaleway-sdk-go/api/redis/v1`/Cluster#Status.]
54
55 return res, isTerminal, nil
56 },
57 Timeoutscip-go gomod github.com/scaleway/scaleway-sdk-go . `github.com/scaleway/scaleway-sdk-go/internal/async`/WaitSyncConfig#Timeout.: timeout,
58 IntervalStrategyscip-go gomod github.com/scaleway/scaleway-sdk-go . `github.com/scaleway/scaleway-sdk-go/internal/async`/WaitSyncConfig#IntervalStrategy.: asyncscip-go gomod github.com/scaleway/scaleway-sdk-go . `github.com/scaleway/scaleway-sdk-go/internal/async`/.LinearIntervalStrategyscip-go gomod github.com/scaleway/scaleway-sdk-go . `github.com/scaleway/scaleway-sdk-go/internal/async`/LinearIntervalStrategy().(retryInterval),
59 })
60 if err != nil {
61 return nil, errorsscip-go gomod github.com/scaleway/scaleway-sdk-go . `github.com/scaleway/scaleway-sdk-go/errors`/.Wrapscip-go gomod github.com/scaleway/scaleway-sdk-go . `github.com/scaleway/scaleway-sdk-go/errors`/Wrap().(err, "waiting for cluster failed")
62 }
63 return cluster.(*Clusterscip-go gomod github.com/scaleway/scaleway-sdk-go . `github.com/scaleway/scaleway-sdk-go/api/redis/v1`/Cluster#), nil
64 }