v0.4.0 #234
ecton
announced in
Announcements
v0.4.0
#234
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Blog Post: Pending Publish
All changes since last commit: v0.3.0...v0.4.0
Breaking Changes
BonsaiDb now has both an async interface as well as a blocking interface. This
has caused significant changes, but they can be summarized simply:
Connection-related async-compatible traits have had the
Asyncprefix addedto them.
Functions that take parameters of the above traits now are offered in pairs:
a blocking function and an async function with "_async" at the end of the
name. For example,
SerializedCollection::get()is the blocking version ofSerializedCollection::get_async().For
bonsaidb-local, theDatabaseandStoragetypes are now blockingimplementations. Under the hood, BonsaiDb previously used
tokio::task::spawn_blocking()to wrap calls to the database in an asyncAPI. New types,
AsyncDatabaseandAsyncStoragehave been added thatprovide the previous behavior. The types can be converted between each other
using helpers as/into/to_blocking/async available on each type.
These changes allow
bonsaidb-localto be compiled without Tokio. To enabletokio, enable feature
asyncif usingbonsaidb-localdirectly, or enablefeature
local-asyncwhen using thebonsaidbcrate.For
bonsaidb-server, it still uses networking driven by Tokio.Server/CustomServerimplementAsyncStorageConnection, andServercanconvert to
Storagevia theFromtrait for synchronous database access.For
bonsaidb-client,Clientimplements bothAsyncStorageConnectionandStorageConnectionand is safe for use in both synchronous and asynchronouscontexts. In WASM,
Clientonly implementsAsyncStorageConnection. Forall other platforms, the
Clientbuilder supports specifying the Tokioruntime handle if needed. Otherwise, the current runtime will be used or a
default runtime will be created automatically if unavailable.
Connection::query_with_docs/Connection::query_with_connection_docsnowverify the user has permission to
DocumentAction::Get. This allows schemaauthors to allow querying views without allowing the documents themselves to
be fetched.
ViewAction::DeleteDocshas been removed. Delete docs is now composed of twopermissions checks:
ViewAction::Queryto retrieve the list of documents todelete, and
DocumentAction::Deletefor each document retrieved. This ensuresif permission is denied to delete a specific document, it still cannot be
deleted through
delete_docs().All APIs have had their
limitparameters changed fromusizetou32.Since
usizeis platform-dependent, picking a fixed-width type is moreappropriate.
CustomApihas been renamed toApiand changed significantly.On the Server,
Apis are registered on theServerConfiguration. TheApiimplementor is treated as the "request" type and is what
Clients send to theServer. The
Api::Responsetype is what the Server sends to theClient.Out-of-band responses can still be delivered.
On the Client,
Apis can simply be used without any extra steps. If youexpect out-of-band responses, callbacks can be registered when building the
client.
Internally, all BonsaiDb APIs have been refactored to use this -- there is no
distinction.
The
multiuserfeature flag has been removed. In the end this caused a lot ofneedless conditional compilation for removing a single lightweight dependency.
User::assume_identityandRole::assume_identityallow assuming theidentity of a user or role by their unique ID or name. The connection must be
permitted with the newly added
ServerAction::AssumeIdentityfor theappropriate resource name (
user_resource_nameorrole_resource_name).StorageConnection::authenticateandStorageConnection::assume_identityboth return a new instance with the new authentication. This enables
authenticating as multiple roles with the same underlying storage connection.
StorageConnection::session()is a new function that returns the currentSession, if one exists. This new type contains information about anycurrently authenticated identity, the unique id of the session, and the
current effective permissions.
This release note applies equally to
AsyncStorageConnection.LowLevelConnectionandAsyncLowLevelConnectionhave been added to groupfunctionality that is not generally meant for the average user to utilize. The
methods that were documented as low-level in
Connection/AsyncConnectionhave been moved to this trait. Additionally, new methods that allow performing
operations without the generic types have been added to this trait. This
functionality is what will be useful in providing applications that can
interact with BonsaiDb without having the Schema definitions available.
PubSub/AsyncPubSubnow allows anySerializeimplementation to be used asthe topic parameter. New methods
publish_bytesandpublish_bytes_to_allhave been added enabling publishing raw payloads.
CollectionName/SchemaNamehave had common methods extracted to a trait,Qualified. This was part of a refactoring to share code between these twotypes and the newly introduced
ApiNametype.BackupLocationandVaultKeyStoragehave been changed to blocking traits.bonsaidb-keystorage-s3wraps a tokio Runtime handle as the AWS SDK requiresTokio.
ServerConfigurationnow takes aBackendgeneric parameter, which mustmatch the
CustomServerbeing created. In general the Rust compiler should beable to infer this type based on usage, and therefore shouldn't be a breaking
change to many people.
The
Backendtrait now has an associatedErrortype, which allows forcustom error types to be used. When an error occurs during initialization, it
is returned. Currently, errors that are returned during client connection
handling are printed using
log::errorand ignored.Keyhas had its encoding functionality moved to a new trait,KeyEncoding.KeyEncodinghas been implemented for borrowed representations ofKeytypes.
This change allows all view query and collection access to utilize borrowed
versions of their key types. For example, if a View's
Keytype isString,it is now possible to query the view using an
&strparameter.Added
Range::default()now returns an unbounded range, andBound::default()returns
Bound::Unbounded.Rangenow has several builder-pattern style methods to help constructranges. In general, users should simply use the built-in range operators
(
..,start..,start..end,start..=end), as they are able to representnearly every range pattern. The built-in range operators do not support
specifying an excluded start bound, while the new method
Range::afterallowssetting an excluded start bound.
#215:
StorageConnection::delete_user()is a new function that allowsdeleting a user by name or id. Deleting a user is permitted with the
ServerAction::DeleteUseraction.bonsaidb_core::key::encode_composite_fieldandbonsaidb_core::key::decode_composite_fieldhave been added which allowbuilding more complex
Keyimplementations that are composed of multiplefields. These functions are what the
Keyimplementation for tuples ispowered by.
Keyis now implemented for[u8; N].#221:
headers()has been as a function to all collection listbuilders, enabling querying just the headers of a document.
Transactionnow hasapply()andapply_async(), which the higher-levelAPI to
LowLevelConnection::apply_transaction.ArgonConfigurationcan now be specified when buildingStorageConfiguration/ServerConfigurationusingBuilder::argon.SystemTimeandDurationnow haveKeyimplementations.bonsaidb_core::key::timehas been added which contains a wide array of typesthat enable storing timestamps and durations with limited resolution, powered
by variable integer encoding to reduce the number of bytes needed to encode
the values.
These types are powered by two traits:
TimeResolutionandTimeEpoch. Usingthese traits, the
LimitedResolutionDurationandLimitedResolutionTimestamptypes can be used for completely custom resolutions (e.g., 15 minutes) and
epochs (the base moment in time to store the limited resolution relative to).
By constraining the resolution and using an epoch that is closer to the
average timestamp being stored, we can reduce the number of bytes required to
represent the values from 12 bytes to significantly fewer.
These type aliases have been added in these three categories:
Weeks,Days,Hours,Minutes,Seconds,Milliseconds,Microseconds, andNanoseconds.WeeksSinceUnixEpoch,DaysSinceUnixEpoch, ...TimestampAsWeeks,TimestampAsDays, ...Backend::configure()is a new function that allows aBackendto setconfiguration options on
ServerConfigurationbefore the server isinitialized. This is a good location for
Backends to define theirApis andSchemas.Changed
reduce()in Nebari, a new feature thatallows aggregating the embedded statistics without traversing the entire tree.
The net result is that retrieving a Collection's count should be near instant
and returning the count of a range of keys should be very fast as well.
StorageConnection::create_database/AsyncStorageConnection::create_databasenow returns the newly created database.
Fixed
return an error.
This discussion was created from the release v0.4.0.
Beta Was this translation helpful? Give feedback.
All reactions