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 re
(opts ...JSOpt)
| 398 | // returned (for a single server setup). For clustered topologies, AccountInfo |
| 399 | // will time out. |
| 400 | func (js *js) AccountInfo(opts ...JSOpt) (*AccountInfo, error) { |
| 401 | o, cancel, err := getJSContextOpts(js.opts, opts...) |
| 402 | if err != nil { |
| 403 | return nil, err |
| 404 | } |
| 405 | if cancel != nil { |
| 406 | defer cancel() |
| 407 | } |
| 408 | |
| 409 | resp, err := js.apiRequestWithContext(o.ctx, js.apiSubj(apiAccountInfo), nil) |
| 410 | if err != nil { |
| 411 | // todo maybe nats server should never have no responder on this subject and always respond if they know there is no js to be had |
| 412 | if errors.Is(err, ErrNoResponders) { |
| 413 | err = ErrJetStreamNotEnabled |
| 414 | } |
| 415 | return nil, err |
| 416 | } |
| 417 | var info accountInfoResponse |
| 418 | if err := json.Unmarshal(resp.Data, &info); err != nil { |
| 419 | return nil, err |
| 420 | } |
| 421 | if info.Error != nil { |
| 422 | // Internally checks based on error code instead of description match. |
| 423 | if errors.Is(info.Error, ErrJetStreamNotEnabledForAccount) { |
| 424 | return nil, ErrJetStreamNotEnabledForAccount |
| 425 | } |
| 426 | return nil, info.Error |
| 427 | } |
| 428 | |
| 429 | return &info.AccountInfo, nil |
| 430 | } |
| 431 | |
| 432 | type createConsumerRequest struct { |
| 433 | Stream string `json:"stream_name"` |
no test coverage detected