Skip to content

Instantly share code, notes, and snippets.

@marcingolenia
Created April 12, 2022 08:54
Show Gist options
  • Save marcingolenia/28036753c5c8a96edcfe87cbc2d6d4c8 to your computer and use it in GitHub Desktop.
Save marcingolenia/28036753c5c8a96edcfe87cbc2d6d4c8 to your computer and use it in GitHub Desktop.
Connect to secure eventstoredb in F#
open System
open System.Text
open EventStore.Client
open Xunit
[<Fact>]
let ``Connect to event store`` () =
// Arrange
let data: string = "{ \"a\":\"2\"}"
let metadata: string = "{}"
use connection = new EventStoreClient(EventStoreClientSettings.Create "esdb://eventstore1.northeurope.cloudapp.azure.com:2113?tls=true")
let events: System.Collections.Generic.IEnumerable<EventData> = [ EventData(
Uuid.NewUuid(),
"typoszcze",
data |> Encoding.UTF8.GetBytes |> ReadOnlyMemory<byte>,
metadata |> Encoding.UTF8.GetBytes |> ReadOnlyMemory<byte>) ]
connection.AppendToStreamAsync("baba", StreamRevision.FromInt64 0 , events) |> Async.AwaitTask |> Async.RunSynchronously
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment