33
44#if ! USE_ LOCAL_ BUILD
55(* Rider's FSI is not happy without the explicit references :shrug: *)
6- #I " bin/Debug/net6 .0"
6+ #I " bin/Debug/net9 .0"
77#r " FsCodec.dll"
88#r " System.Text.Json.dll"
99#r " FsCodec.SystemTextJson.dll"
@@ -208,7 +208,7 @@ module Events =
208208 interface TypeShape.UnionContract.IUnionContract
209209 let codec = Store.codec< Event>
210210
211- let utf8 ( s : string ) = System.Text.Encoding.UTF8.GetBytes( s) |> ReadOnlyMemory
211+ let utf8 ( s : string ) = System.Text.Encoding.UTF8.GetBytes( s) |> FsCodec.Encoding.OfBlob
212212let streamForClient c = Stream.name ( ClientId.parse c)
213213let events = [
214214 Stream.name ( ClientId.parse " ClientA" ), FsCodec.Core.TimelineEvent.Create( 0 L, " Added" , utf8 """ { "item": "a" }""" )
@@ -235,13 +235,13 @@ Log.initWithDebugLevel ()
235235
236236(* Explicit matching, showing how some ugly things get into the code if you do the streamName matching and event parsing separately *)
237237
238- // When we obtain events from an event store via streaming notifications, we typically receive them as ReadOnlyMemory<byte> bodies
238+ // When we obtain events from an event store via streaming notifications, we typically receive them as FsCodec.Encoded or ReadOnlyMemory<byte> bodies
239239type Event = FsCodec.ITimelineEvent< EventBody>
240- and EventBody = ReadOnlyMemory < byte >
240+ and EventBody = FsCodec.Encoded
241241and Codec < 'E > = FsCodec.IEventCodec< 'E, EventBody, unit>
242242
243243let streamCodec < 'E when 'E :> TypeShape.UnionContract.IUnionContract > : Codec < 'E > =
244- Codec.Create< 'E>( serdes = Store.serdes)
244+ Codec.Create< 'E>( serdes = Store.serdes) |> FsCodec.Encoder.Uncompressed
245245
246246let dec = streamCodec< Events.Event>
247247let [<return:Struct>] (| DecodeEvent | _ |) ( codec : Codec < 'E >) event = codec.Decode event
@@ -299,19 +299,19 @@ module Streams =
299299 // Events coming from streams are carried as a TimelineEvent; the body type is configurable
300300 type Event = FsCodec.ITimelineEvent< EventBody>
301301 // Propulsion's Sinks by default use ReadOnlyMemory<byte> as the storage format
302- and EventBody = ReadOnlyMemory < byte >
302+ and EventBody = FsCodec.Encoded
303303 // the above Events can be decoded by a Codec implementing this interface
304304 and Codec < 'E > = FsCodec.IEventCodec< 'E, EventBody, unit>
305305
306306 /// Generates a Codec for the specified Event Union type
307307 let codec < 'E when 'E :> TypeShape.UnionContract.IUnionContract > : Codec < 'E > =
308308 // Borrowing the Store serdes; frequently the events you parse can use less complex options...
309- Codec.Create< 'E>( serdes = Store.serdes)
309+ Codec.Create< 'E>( serdes = Store.serdes) |> FsCodec.Encoder.Uncompressed
310310
311311 // as we know our event bodies are all UTF8 encoded JSON, we can render the string as a log event property
312312 // alternately, you can render the EventBody directly and ensure you have appropriate type destructuring configured
313313 let private render ( x : EventBody ): string =
314- System.Text. Encoding.UTF8.GetString ( x.Span )
314+ FsCodec. Encoding.GetStringUtf8 x
315315 /// Uses the supplied codec to decode the supplied event record ` x `
316316 /// (iff at LogEventLevel.Debug, detail fails to ` log ` citing the ` streamName ` and body)
317317 let decode < 'E > ( log : Serilog.ILogger ) ( codec : Codec < 'E >) ( streamName : FsCodec.StreamName ) ( x : Event ) =
@@ -463,11 +463,11 @@ module StreamsWithMeta =
463463
464464 let codec < 'E when 'E :> TypeShape.UnionContract.IUnionContract > : Codec < 'E > =
465465 // here we surface some metadata from the raw event as part of the application level type
466- let up ( raw : Streams.Event ) ( contract : 'E ): Event < 'E > =
466+ let up ( raw : FsCodec.ITimelineEvent < ReadOnlyMemory < byte >> ) ( contract : 'E ): Event < 'E > =
467467 struct ( raw.Index, serdes.Deserialize< Metadata> raw.Meta, contract)
468468 // We are not using this codec to encode events, so we let the encoding side fail very fast
469469 let down _ = failwith " N/A"
470- Codec.Create< Event< 'E>, 'E, Metadata>( up, down, serdes = Store.serdes)
470+ Codec.Create< Event< 'E>, 'E, Metadata>( up, down, serdes = Store.serdes) |> FsCodec.Encoder.Uncompressed
471471
472472let eventsWithMeta = seq {
473473 for sn, e in events ->
0 commit comments