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
-
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
Async
prefix 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
, theDatabase
andStorage
types are now blockingimplementations. Under the hood, BonsaiDb previously used
tokio::task::spawn_blocking()
to wrap calls to the database in an asyncAPI. New types,
AsyncDatabase
andAsyncStorage
have 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-local
to be compiled without Tokio. To enabletokio, enable feature
async
if usingbonsaidb-local
directly, or enablefeature
local-async
when using thebonsaidb
crate.For
bonsaidb-server
, it still uses networking driven by Tokio.Server
/CustomServer
implementAsyncStorageConnection
, andServer
canconvert to
Storage
via theFrom
trait for synchronous database access.For
bonsaidb-client
,Client
implements bothAsyncStorageConnection
andStorageConnection
and is safe for use in both synchronous and asynchronouscontexts. In WASM,
Client
only implementsAsyncStorageConnection
. Forall other platforms, the
Client
builder 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_docs
nowverify the user has permission to
DocumentAction::Get
. This allows schemaauthors to allow querying views without allowing the documents themselves to
be fetched.
ViewAction::DeleteDocs
has been removed. Delete docs is now composed of twopermissions checks:
ViewAction::Query
to retrieve the list of documents todelete, and
DocumentAction::Delete
for 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
limit
parameters changed fromusize
tou32
.Since
usize
is platform-dependent, picking a fixed-width type is moreappropriate.
CustomApi
has been renamed toApi
and changed significantly.On the Server,
Api
s are registered on theServerConfiguration
. TheApi
implementor is treated as the "request" type and is what
Client
s send to theServer. The
Api::Response
type is what the Server sends to theClient
.Out-of-band responses can still be delivered.
On the Client,
Api
s 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
multiuser
feature flag has been removed. In the end this caused a lot ofneedless conditional compilation for removing a single lightweight dependency.
User::assume_identity
andRole::assume_identity
allow assuming theidentity of a user or role by their unique ID or name. The connection must be
permitted with the newly added
ServerAction::AssumeIdentity
for theappropriate resource name (
user_resource_name
orrole_resource_name
).StorageConnection::authenticate
andStorageConnection::assume_identity
both 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
.LowLevelConnection
andAsyncLowLevelConnection
have 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
/AsyncConnection
have 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
/AsyncPubSub
now allows anySerialize
implementation to be used asthe topic parameter. New methods
publish_bytes
andpublish_bytes_to_all
have been added enabling publishing raw payloads.
CollectionName
/SchemaName
have had common methods extracted to a trait,Qualified
. This was part of a refactoring to share code between these twotypes and the newly introduced
ApiName
type.BackupLocation
andVaultKeyStorage
have been changed to blocking traits.bonsaidb-keystorage-s3
wraps a tokio Runtime handle as the AWS SDK requiresTokio.
ServerConfiguration
now takes aBackend
generic parameter, which mustmatch the
CustomServer
being 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
Backend
trait now has an associatedError
type, 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::error
and ignored.Key
has had its encoding functionality moved to a new trait,KeyEncoding
.KeyEncoding
has been implemented for borrowed representations ofKey
types.
This change allows all view query and collection access to utilize borrowed
versions of their key types. For example, if a View's
Key
type isString
,it is now possible to query the view using an
&str
parameter.Added
Range::default()
now returns an unbounded range, andBound::default()
returns
Bound::Unbounded
.Range
now 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::after
allowssetting 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::DeleteUser
action.bonsaidb_core::key::encode_composite_field
andbonsaidb_core::key::decode_composite_field
have been added which allowbuilding more complex
Key
implementations that are composed of multiplefields. These functions are what the
Key
implementation for tuples ispowered by.
Key
is now implemented for[u8; N]
.#221:
headers()
has been as a function to all collection listbuilders, enabling querying just the headers of a document.
Transaction
now hasapply()
andapply_async()
, which the higher-levelAPI to
LowLevelConnection::apply_transaction
.ArgonConfiguration
can now be specified when buildingStorageConfiguration
/ServerConfiguration
usingBuilder::argon
.SystemTime
andDuration
now haveKey
implementations.bonsaidb_core::key::time
has 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:
TimeResolution
andTimeEpoch
. Usingthese traits, the
LimitedResolutionDuration
andLimitedResolutionTimestamp
types 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 aBackend
to setconfiguration options on
ServerConfiguration
before the server isinitialized. This is a good location for
Backend
s to define theirApi
s andSchema
s.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_database
now 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