Skip to content

Commit

Permalink
[IMPROVED] Documentation for AccountInfo and ErrJetStreamNotEnabled (#…
Browse files Browse the repository at this point in the history
…1605)

Signed-off-by: Piotr Piotrowski <piotr@synadia.com>
  • Loading branch information
piotrpio committed Apr 5, 2024
1 parent dc22a66 commit 46be740
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 6 deletions.
4 changes: 4 additions & 0 deletions jetstream/errors.go
Expand Up @@ -71,6 +71,10 @@ var (

// ErrJetStreamNotEnabled is an error returned when JetStream is not
// enabled.
//
// Note: This error will not be returned in clustered mode, even if each
// server in the cluster does not have JetStream enabled. In clustered mode,
// requests will time out instead.
ErrJetStreamNotEnabled JetStreamError = &jsError{apiErr: &APIError{ErrorCode: JSErrCodeJetStreamNotEnabled, Description: "jetstream not enabled", Code: 503}}

// ErrJetStreamNotEnabledForAccount is an error returned when JetStream is
Expand Down
8 changes: 5 additions & 3 deletions jetstream/jetstream.go
Expand Up @@ -791,9 +791,11 @@ func validateSubject(subject string) error {

// AccountInfo fetches account information from the server, containing details
// about the account associated with this JetStream connection. If account is
// not enabled for JetStream, ErrJetStreamNotEnabledForAccount is returned. If
// the server does not have JetStream enabled, ErrJetStreamNotEnabled is
// returned.
// not enabled for JetStream, ErrJetStreamNotEnabledForAccount is returned.
//
// If the server does not have JetStream enabled, ErrJetStreamNotEnabled is
// returned (for a single server setup). For clustered topologies, AccountInfo
// will time out.
func (js *jetStream) AccountInfo(ctx context.Context) (*AccountInfo, error) {
ctx, cancel := wrapContextWithoutDeadline(ctx)
if cancel != nil {
Expand Down
4 changes: 4 additions & 0 deletions jserrors.go
Expand Up @@ -22,6 +22,10 @@ var (
// API errors

// ErrJetStreamNotEnabled is an error returned when JetStream is not enabled for an account.
//
// Note: This error will not be returned in clustered mode, even if each
// server in the cluster does not have JetStream enabled. In clustered mode,
// requests will time out instead.
ErrJetStreamNotEnabled JetStreamError = &jsError{apiErr: &APIError{ErrorCode: JSErrCodeJetStreamNotEnabled, Description: "jetstream not enabled", Code: 503}}

// ErrJetStreamNotEnabledForAccount is an error returned when JetStream is not enabled for an account.
Expand Down
10 changes: 7 additions & 3 deletions jsm.go
Expand Up @@ -288,9 +288,13 @@ type accountInfoResponse struct {
AccountInfo
}

// AccountInfo retrieves info about the JetStream usage from the current account.
// If JetStream is not enabled, this will return ErrJetStreamNotEnabled
// Other errors can happen but are generally considered retryable
// AccountInfo fetches account information from the server, containing details
// about the account associated with this JetStream connection. If account is
// not enabled for JetStream, ErrJetStreamNotEnabledForAccount is returned.
//
// If the server does not have JetStream enabled, ErrJetStreamNotEnabled is
// returned (for a single server setup). For clustered topologies, AccountInfo
// will time out.
func (js *js) AccountInfo(opts ...JSOpt) (*AccountInfo, error) {
o, cancel, err := getJSContextOpts(js.opts, opts...)
if err != nil {
Expand Down

0 comments on commit 46be740

Please sign in to comment.