有没有办法启动在 Windows 中提供的 EventStore(根本不使用 docker)?

Liv*_*osu 5 .net c# event-sourcing eventstoredb

我正在玩EventStore。作为 .NET 用户,我更喜欢 Windows 作为操作系统,只是我有家庭版。为了安装 Docker,我需要 Windows 专业版——但我没有……这超出了我的预算。

无论如何,我一直在尝试安装(通过 Chocolatey)并且我成功了。我该如何开始?我在文档中找不到该命令。

我有这个代码:

var settings = new EventStoreClientSettings {
    ConnectivitySettings = {
        Address = new Uri("http://localhost:2113")
    }
};

var client = new EventStoreClient(settings);
Run Code Online (Sandbox Code Playgroud)

取自这里

我收到一个错误“启动 gRPC 调用时出错 - 无法创建连接”。

我怀疑我需要启动服务器。但是如何?即使我使用 docker,我仍然无法使用命令行启动服务器,因为我的经验告诉我,我会在这种情况下这样做。

我很乐意联系他们的支持,但我只是在探索 - 我没有这个软件的许可证。

CCo*_*ron 4

对于 GRPC,请从https://www.eventstore.com/downloads下载 zip 文件并解压到本地文件夹或eventstore-osschoco安装

对于版本 20.10 运行 EventStore.ClusterNode.exe --insecure --run-projections=all --start-standard-projections --enable-atom-pub-over-http

在浏览器中打开localhost:2113并确认数据库正在运行

使用esdb://localhost:2113?Tls=falsegRPC 客户端的连接字符串。.net 3.1 控制台应用程序

es-connect.csproj文件

<Project Sdk="Microsoft.NET.Sdk">

  <PropertyGroup>
    <OutputType>Exe</OutputType>
    <TargetFramework>netcoreapp3.1</TargetFramework>
  </PropertyGroup>

  <ItemGroup>   
    <PackageReference Include="EventStore.Client.Grpc.Streams" Version="20.6.1" />
  </ItemGroup>

</Project>
Run Code Online (Sandbox Code Playgroud)

main.cs文件

using EventStore.Client;
using System;
using System.Collections.Generic;
using System.Text;
using System.Threading.Tasks;

namespace connections
{
    class Program
    {

        public static async Task Main()
        {
            var settings = EventStoreClientSettings.Create("esdb://localhost:2113?tls=false");
            var client = new EventStoreClient(settings);
            var itemId = Guid.NewGuid();
            var streamName = $"item-{itemId}";
            var eventData1 = new EventData(
                                    Uuid.NewUuid(), //event id
                                    "ItemCreated", //event type name
                                    Encoding.UTF8.GetBytes($@"{{""item-id"": ""{itemId}"", ""a-starting-value"": ""foo""}}"), //event data
                                    Encoding.UTF8.GetBytes($@"{{""written-by"": ""me"", ""written-at"":""{DateTime.UtcNow}""}}") // event metadata
                                    );
            var eventData2 = new EventData(
                                    Uuid.NewUuid(), //event id
                                    "ItemChanged", //event type name
                                    Encoding.UTF8.GetBytes($@"{{""item-id"": ""{itemId}"", ""a-new-value"": ""foo""}}"), //event data
                                    Encoding.UTF8.GetBytes($@"{{""written-by"": ""me"", ""written-at"":""{DateTime.UtcNow}""}}") // event metadata
                                    ); 

            var rslt = await client.AppendToStreamAsync(
                streamName,
                StreamState.NoStream,
                new List<EventData> { eventData1,eventData2 });

            Console.WriteLine($"Wrote events through number {rslt.NextExpectedStreamRevision} at {rslt.LogPosition}");
            Console.WriteLine();

            var events = client.ReadStreamAsync(Direction.Forwards, streamName, StreamPosition.Start, 100);

            await foreach (var @event in events)
            {
                Console.WriteLine($"Event Postion:{@event.OriginalEvent.Position}");
                Console.WriteLine($"Event Number:{@event.OriginalEventNumber}");
                Console.WriteLine($"Event Id:{@event.OriginalEvent.EventId}");
                Console.WriteLine($"data:{Encoding.UTF8.GetString(@event.Event.Data.Span)}");
                Console.WriteLine($"metadata:{Encoding.UTF8.GetString(@event.Event.Metadata.Span)}");
                Console.WriteLine();
            }

        }
    }
}
Run Code Online (Sandbox Code Playgroud)

浏览以http://localhost:2113/web/index.html#/streams确认写入的流。
单击流详细信息(例如http://localhost:2113/web/index.html#/streams/item-{item id}
http://localhost:2113/web/index.html#/streams/item-{item id}\0一个事件)的链接

项目类别位于http://localhost:2113/web/index.html#/streams/$ce-item
ItemCreated 事件中,位于http://localhost:2113/web/index.html#/streams/$et-ItemCreated
ItemChanged 事件中http://localhost:2113/web/index.html#/streams/$et-ItemChanged