Skip to content

Latest commit

 

History

History
72 lines (60 loc) · 4.99 KB

File metadata and controls

72 lines (60 loc) · 4.99 KB

Client examples

These code examples are best practice usage of the client

Connecting to EventStoreDB

The preferred way of configuring a client is by using a connection string. In most cases, you would need to configure a secure connection. The following example show how to create a EventStoreStreamsClient with a connection string:

final settings = EventStoreClientSettings.parse('{connectionString}');
final streamsClient = EventStoreStreamsClient(settings);

The same pattern applies for all clients. These are examples of connection strings that all Dart clients support:

// Single node
EventStoreClientSettings.parse("esdb://localhost"); // with hostname only
EventStoreClientSettings.parse("esdb://localhost:2113"); // with hostname and port
EventStoreClientSettings.parse("esdb://user:pass@localhost:2113"); // with username and password
EventStoreClientSettings.parse("esdb://user:pass@localhost:2113/"); // extra forward slash also works
EventStoreClientSettings.parse("esdb://user:pass@localhost:2113?tlsVerifyCert=false"); // disables server certificate validation
EventStoreClientSettings.parse("esdb://user:pass@localhost:2113?tls=false"); // connects over http instead of https

// Cluster
EventStoreClientSettings.parse("esdb://host1,host2,host3"); // with hostnames only
EventStoreClientSettings.parse("esdb://host1:1234,host2:4321,host3:3231"); // with hostnames and port
EventStoreClientSettings.parse("esdb://user:pass@host1:1234,host2:4321,host3:3231?nodePreference=follower"); // with username and password
EventStoreClientSettings.parse("esdb://host1,host2,host3?tls=false"); // connects over http instead of https
EventStoreClientSettings.parse("esdb://host1,host2,host3?tlsVerifyCert=false"); // disables server certificate validation

The following clients are available

See official documentation for more information about connections to EventStoreDB.

Working with Streams

The EventStoreStreamsClient is the primary client for working with streams in EventStoreDB. The following examples show how you should use it:

Working with Projections

The EventStoreProjectionsClient is the primary client for working with projections in EventStoreDB. The following example show how you should use it:

  • TDB

Working with Persistent subscriptions

The EventStorePersistentSubscriptionsClient is the primary client for working with persistent projections in EventStoreDB. The following example show how you should use it:

  • TDB