mirror of
https://github.com/gogrlx/nats-server.git
synced 2026-04-17 11:24:44 -07:00
Add in tracking for quorum in raft and do auto stepdown.
Also added in API responses when no leader is present for meta, streams and consumers. Signed-off-by: Derek Collison <derek@nats.io>
This commit is contained in:
11
vendor/github.com/nats-io/nats.go/js.go
generated
vendored
11
vendor/github.com/nats-io/nats.go/js.go
generated
vendored
@@ -131,20 +131,13 @@ func (nc *Conn) JetStream(opts ...JSOpt) (JetStreamContext, error) {
|
||||
return js, nil
|
||||
}
|
||||
|
||||
resp, err := nc.Request(js.apiSubj(apiAccountInfo), nil, js.wait)
|
||||
if err != nil {
|
||||
if _, err := js.AccountInfo(); err != nil {
|
||||
if err == ErrNoResponders {
|
||||
err = ErrJetStreamNotEnabled
|
||||
}
|
||||
return nil, err
|
||||
}
|
||||
var info accountInfoResponse
|
||||
if err := json.Unmarshal(resp.Data, &info); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if info.Error != nil && info.Error.Code == 503 {
|
||||
return nil, ErrJetStreamNotEnabled
|
||||
}
|
||||
|
||||
return js, nil
|
||||
}
|
||||
|
||||
|
||||
53
vendor/github.com/nats-io/nats.go/jsm.go
generated
vendored
53
vendor/github.com/nats-io/nats.go/jsm.go
generated
vendored
@@ -55,6 +55,9 @@ type JetStreamManager interface {
|
||||
|
||||
// NewConsumerLister is used to return pages of ConsumerInfo objects.
|
||||
NewConsumerLister(stream string) *ConsumerLister
|
||||
|
||||
// AccountInfo retrieves info about the JetStream usage from an account.
|
||||
AccountInfo() (*AccountInfo, error)
|
||||
}
|
||||
|
||||
// StreamConfig will determine the properties for a stream.
|
||||
@@ -102,22 +105,48 @@ type apiPagedRequest struct {
|
||||
Offset int `json:"offset"`
|
||||
}
|
||||
|
||||
// accountStats returns current statistics about the account's JetStream usage.
|
||||
type accountStats struct {
|
||||
Memory uint64 `json:"memory"`
|
||||
Store uint64 `json:"storage"`
|
||||
Streams int `json:"streams"`
|
||||
Limits struct {
|
||||
MaxMemory int64 `json:"max_memory"`
|
||||
MaxStore int64 `json:"max_storage"`
|
||||
MaxStreams int `json:"max_streams"`
|
||||
MaxConsumers int `json:"max_consumers"`
|
||||
} `json:"limits"`
|
||||
// AccountInfo contains info about the JetStream usage from the current account.
|
||||
type AccountInfo struct {
|
||||
Memory uint64 `json:"memory"`
|
||||
Store uint64 `json:"storage"`
|
||||
Streams int `json:"streams"`
|
||||
Limits AccountLimits `json:"limits"`
|
||||
}
|
||||
|
||||
// AccountLimits includes the JetStream limits of the current account.
|
||||
type AccountLimits struct {
|
||||
MaxMemory int64 `json:"max_memory"`
|
||||
MaxStore int64 `json:"max_storage"`
|
||||
MaxStreams int `json:"max_streams"`
|
||||
MaxConsumers int `json:"max_consumers"`
|
||||
}
|
||||
|
||||
type accountInfoResponse struct {
|
||||
apiResponse
|
||||
accountStats
|
||||
AccountInfo
|
||||
}
|
||||
|
||||
// AccountInfo retrieves info about the JetStream usage from the current account.
|
||||
func (js *js) AccountInfo() (*AccountInfo, error) {
|
||||
resp, err := js.nc.Request(js.apiSubj(apiAccountInfo), nil, js.wait)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
var info accountInfoResponse
|
||||
if err := json.Unmarshal(resp.Data, &info); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if info.Error != nil {
|
||||
var err error
|
||||
if strings.Contains(info.Error.Description, "not enabled for") {
|
||||
err = ErrJetStreamNotEnabled
|
||||
} else {
|
||||
err = errors.New(info.Error.Description)
|
||||
}
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return &info.AccountInfo, nil
|
||||
}
|
||||
|
||||
type createConsumerRequest struct {
|
||||
|
||||
Reference in New Issue
Block a user