github.com/minio/madmin-go@v1.7.5/examples/cluster-health.go (about) 1 //go:build ignore 2 // +build ignore 3 4 // 5 // MinIO Object Storage (c) 2022 MinIO, Inc. 6 // 7 // Licensed under the Apache License, Version 2.0 (the "License"); 8 // you may not use this file except in compliance with the License. 9 // You may obtain a copy of the License at 10 // 11 // http://www.apache.org/licenses/LICENSE-2.0 12 // 13 // Unless required by applicable law or agreed to in writing, software 14 // distributed under the License is distributed on an "AS IS" BASIS, 15 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 // See the License for the specific language governing permissions and 17 // limitations under the License. 18 // 19 20 package main 21 22 import ( 23 "context" 24 "log" 25 26 "github.com/minio/madmin-go" 27 ) 28 29 func main() { 30 // API requests are secure (HTTPS) if secure=true and insecure (HTTPS) otherwise. 31 // NewAnonymousClient returns an anonymous MinIO Admin client object. 32 // Anonymous client doesn't require any credentials 33 madmAnonClnt, err := madmin.NewAnonymousClient("your-minio.example.com:9000", true) 34 if err != nil { 35 log.Fatalln(err) 36 } 37 // To enable trace :- 38 // madmAnonClnt.TraceOn(os.Stderr) 39 opts := madmin.HealthOpts{ 40 ClusterRead: false, // set to "true" to check if the cluster has read quorum 41 Maintenance: false, // set to "true" to check if the cluster is taken down for maintenance 42 } 43 healthResult, err := madmAnonClnt.Healthy(context.Background(), opts) 44 if err != nil { 45 log.Fatalln(err) 46 } 47 log.Println(healthResult) 48 }