F# 在F中从Logary/Noop.fs创建日志函数#

F# 在F中从Logary/Noop.fs创建日志函数#,f#,F#,我正在从编辑Noop.fs文件 我目前正在尝试添加两个函数。这就是创建事件源连接的方法(我知道我应该将其理想地移动到其他地方,这样它就不会在每次我想要记录某个内容时创建,而是应该存在于全局级别,然后我应该将其添加到哪里?) 第二个功能是将日志作为事件发送到EventStore流。我已经创建了这个函数,但是我需要调用它。我把它叫哪里?我试着把它放在函数下面,但它不起作用 另一个错误在这条线上 ack *<= () (* LHS: the ACK is a unit sent to `ack`

我正在从编辑Noop.fs文件

我目前正在尝试添加两个函数。这就是创建事件源连接的方法(我知道我应该将其理想地移动到其他地方,这样它就不会在每次我想要记录某个内容时创建,而是应该存在于全局级别,然后我应该将其添加到哪里?)

第二个功能是将日志作为事件发送到EventStore流。我已经创建了这个函数,但是我需要调用它。我把它叫哪里?我试着把它放在函数下面,但它不起作用

另一个错误在这条线上

ack *<= () (* LHS: the ACK is a unit sent to `ack` *) >>= fun () ->
ack*>=fun()->
错误:FS0010表达式中存在意外标识符。在此点或其他标记处或之前应为不完整的结构化构造

这是我的代码:

 | Log (message, ack) ->

         let CreateEventSourcingConnection() =
             task {
                 let connection =
                     let ipEndPoint = IPEndPoint(IPAddress.Loopback, 1113)
                     EventStoreConnection.Create(ipEndlPoint)
                 do! connection.ConnectAsync()
                 return connection
             }

         let AddEventToStreamAsync (connection: IEventStoreConnection) streamName eventName message =
             task {
                 let serializedEventData =
                     message
                     |> JsonConvert.SerializeObject
                     |> Encoding.UTF8.GetBytes
                 let event = EventData(Guid.NewGuid(), eventName, true, serializedEventData, null)

                 let! _ = connection.AppendToStreamAsync(streamName, int64 ExpectedVersion.Any, event)
                 ()
             }
         ()

         //Do something with the `message` value specific to the target
         //you are creating.

         //Don't put `use` statements in here; you need to dispose them before
         //recursing below.

         //This is a simple acknowledgement using unit as the signal
        ack *<= () (* LHS: the ACK is a unit sent to `ack` *) >>= fun () ->
                    (* RHS (above): the callback after the ACK is done *)
        loop { state = not state.state } // recurse
|日志(消息,确认)->
让CreateEventSourcingConnection()=
任务{
让连接=
让ipEndPoint=ipEndPoint(IPAddress.Loopback,1113)
EventStoreConnection.Create(ipEndlPoint)
do!connection.ConnectAsync()
回路连接
}
让AddEventToStreamAsync(连接:IEventStoreConnection)streamName事件名称消息=
任务{
让我们序列化deventdata=
消息
|>JsonConvert.SerializeObject
|>Encoding.UTF8.GetBytes
let event=EventData(Guid.NewGuid(),eventName,true,serializedEventData,null)
let!\ux=connection.AppendToStreamAsync(streamName,int64 ExpectedVersion.Any,事件)
()
}
()
//使用特定于目标的'message'值执行某些操作
//你正在创造。
//不要在这里放“use”语句;你需要先把它们处理掉
//在下面递归。
//这是一个使用单元作为信号的简单确认
ack*>=fun()->
(*RHS(上图):确认完成后的回调*)
循环{state=notstate.state}//递归