MCPcopy
hub / github.com/minio/minio-go / main

Function main

examples/s3/healthcheck.go:31–58  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

29)
30
31func main() {
32 // Note: YOUR-ACCESSKEYID, YOUR-SECRETACCESSKEY, my-bucketname and my-objectname
33 // are dummy values, please replace them with original values.
34
35 // Requests are always secure (HTTPS) by default. Set secure=false to enable insecure (HTTP) access.
36 // This boolean value is the last argument for New().
37
38 // New returns an Amazon S3 compatible client object. API compatibility (v2 or v4) is automatically
39 // determined based on the Endpoint value.
40 s3Client, err := minio.New("s3.amazonaws.com", &minio.Options{
41 Creds: credentials.NewStaticV4("YOUR-ACCESSKEYID", "YOUR-SECRETACCESSKEY", ""),
42 Secure: true,
43 })
44 if err != nil {
45 log.Fatalln(err)
46 }
47 // start healthcheck on the endpoint
48 cancelFn, err := s3Client.HealthCheck(5 * time.Second)
49 if err == nil {
50 defer cancelFn()
51 }
52 for {
53 if s3Client.IsOnline() {
54 // do some S3 operations
55 }
56 time.Sleep(1 * time.Second)
57 }
58}

Callers

nothing calls this directly

Calls 3

NewStaticV4Function · 0.92
HealthCheckMethod · 0.80
IsOnlineMethod · 0.80

Tested by

no test coverage detected