Skip to content

Commit

Permalink
[ADDED] KV implementation in new JetStream API
Browse files Browse the repository at this point in the history
Signed-off-by: Piotr Piotrowski <[email protected]>
  • Loading branch information
piotrpio committed Aug 4, 2023
1 parent f95d02a commit 69db83a
Show file tree
Hide file tree
Showing 11 changed files with 2,405 additions and 39 deletions.
34 changes: 34 additions & 0 deletions jetstream/errors.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,8 @@ const (
JSErrCodeMessageNotFound ErrorCode = 10037

JSErrCodeBadRequest ErrorCode = 10003

JSErrCodeStreamWrongLastSequence ErrorCode = 10071
)

var (
Expand Down Expand Up @@ -178,6 +180,38 @@ var (
// ErrOrderedConsumerNotCreated is returned when trying to get consumer info of an
// ordered consumer which was not yet created.
ErrOrderedConsumerNotCreated = &jsError{message: "consumer instance not yet created"}

// KeyValue Errors

// ErrKeyExists is returned when attempting to create a key that already exists.
ErrKeyExists JetStreamError = &jsError{apiErr: &APIError{ErrorCode: JSErrCodeStreamWrongLastSequence, Code: 400}, message: "key exists"}

// ErrKeyValueConfigRequired is returned when attempting to create a bucket without a config.
ErrKeyValueConfigRequired = &jsError{message: "config required"}

// ErrInvalidBucketName is returned when attempting to create a bucket with an invalid name.
ErrInvalidBucketName = &jsError{message: "invalid bucket name"}

// ErrInvalidKey is returned when attempting to create a key with an invalid name.
ErrInvalidKey = &jsError{message: "invalid key"}

// ErrBucketNotFound is returned when attempting to access a bucket that does not exist.
ErrBucketNotFound = &jsError{message: "bucket not found"}

// ErrBadBucket is returned when attempting to access a bucket that is not a key-value store.
ErrBadBucket = &jsError{message: "bucket not valid key-value store"}

// ErrKeyNotFound is returned when attempting to access a key that does not exist.
ErrKeyNotFound = &jsError{message: "key not found"}

// ErrKeyDeleted is returned when attempting to access a key that was deleted.
ErrKeyDeleted = &jsError{message: "key was deleted"}

// ErrHistoryToLarge is returned when provided history limit is larger than 64.
ErrHistoryToLarge = &jsError{message: "history limited to a max of 64"}

// ErrNoKeysFound is returned when no keys are found.
ErrNoKeysFound = &jsError{message: "no keys found"}
)

// Error prints the JetStream API error code and description
Expand Down
1 change: 1 addition & 0 deletions jetstream/jetstream.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ type (
StreamConsumerManager
StreamManager
Publisher
KeyValueManager
}

Publisher interface {
Expand Down
Loading

0 comments on commit 69db83a

Please sign in to comment.