Object Store

The Object Store allows you to store data of any (i.e. large) size by implementing a chunking mechanism, allowing you to for example store and retrieve files (i.e. the object) of any size by associating them with a path and a file name (i.e. the key). You obtain a ObjectStoreManager object from your JetStream context.

{% tabs %} {% tab title=”Go” %}

  1. // ObjectStoreManager creates, loads and deletes Object Stores
  2. //
  3. // This functionality is EXPERIMENTAL and may be changed in later releases.
  4. type ObjectStoreManager interface {
  5. // ObjectStore will lookup and bind to an existing object store instance.
  6. ObjectStore(bucket string) (ObjectStore, error)
  7. // CreateObjectStore will create an object store.
  8. CreateObjectStore(cfg *ObjectStoreConfig) (ObjectStore, error)
  9. // DeleteObjectStore will delete the underlying stream for the named object.
  10. DeleteObjectStore(bucket string) error
  11. }
  12. // ObjectStore is a blob store capable of storing large objects efficiently in
  13. // JetStream streams
  14. //
  15. // This functionality is EXPERIMENTAL and may be changed in later releases.
  16. type ObjectStore interface {
  17. // Put will place the contents from the reader into a new object.
  18. Put(obj *ObjectMeta, reader io.Reader, opts ...ObjectOpt) (*ObjectInfo, error)
  19. // Get will pull the named object from the object store.
  20. Get(name string, opts ...ObjectOpt) (ObjectResult, error)
  21. // PutBytes is convenience function to put a byte slice into this object store.
  22. PutBytes(name string, data []byte, opts ...ObjectOpt) (*ObjectInfo, error)
  23. // GetBytes is a convenience function to pull an object from this object store and return it as a byte slice.
  24. GetBytes(name string, opts ...ObjectOpt) ([]byte, error)
  25. // PutBytes is convenience function to put a string into this object store.
  26. PutString(name string, data string, opts ...ObjectOpt) (*ObjectInfo, error)
  27. // GetString is a convenience function to pull an object from this object store and return it as a string.
  28. GetString(name string, opts ...ObjectOpt) (string, error)
  29. // PutFile is convenience function to put a file into this object store.
  30. PutFile(file string, opts ...ObjectOpt) (*ObjectInfo, error)
  31. // GetFile is a convenience function to pull an object from this object store and place it in a file.
  32. GetFile(name, file string, opts ...ObjectOpt) error
  33. // GetInfo will retrieve the current information for the object.
  34. GetInfo(name string) (*ObjectInfo, error)
  35. // UpdateMeta will update the meta data for the object.
  36. UpdateMeta(name string, meta *ObjectMeta) error
  37. // Delete will delete the named object.
  38. Delete(name string) error
  39. // AddLink will add a link to another object into this object store.
  40. AddLink(name string, obj *ObjectInfo) (*ObjectInfo, error)
  41. // AddBucketLink will add a link to another object store.
  42. AddBucketLink(name string, bucket ObjectStore) (*ObjectInfo, error)
  43. // Seal will seal the object store, no further modifications will be allowed.
  44. Seal() error
  45. // Watch for changes in the underlying store and receive meta information updates.
  46. Watch(opts ...WatchOpt) (ObjectWatcher, error)
  47. // List will list all the objects in this store.
  48. List(opts ...WatchOpt) ([]*ObjectInfo, error)
  49. // Status retrieves run-time status about the backing store of the bucket.
  50. Status() (ObjectStoreStatus, error)
  51. }

{% endtab %} {% endtabs %}