github.com/simpleiot/simpleiot@v0.18.3/client/admin.go (about)

     1  package client
     2  
     3  import (
     4  	"errors"
     5  	"time"
     6  
     7  	"github.com/nats-io/nats.go"
     8  )
     9  
    10  // AdminStoreVerify can be used verify the store
    11  func AdminStoreVerify(nc *nats.Conn) error {
    12  	resp, err := nc.Request("admin.storeVerify", nil, time.Second*20)
    13  	if err != nil {
    14  		return err
    15  	}
    16  
    17  	if len(resp.Data) > 0 {
    18  		return errors.New(string(resp.Data))
    19  	}
    20  
    21  	return nil
    22  }
    23  
    24  // AdminStoreMaint can be used fix store issues
    25  func AdminStoreMaint(nc *nats.Conn) error {
    26  	resp, err := nc.Request("admin.storeMaint", nil, time.Second*20)
    27  	if err != nil {
    28  		return err
    29  	}
    30  
    31  	if len(resp.Data) > 0 {
    32  		return errors.New(string(resp.Data))
    33  	}
    34  
    35  	return nil
    36  }