Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there a way to start the EventStore served in Windows (without using docker at all)?

I am playing with EventStore. As a .NET user I prefer Windows as OS, only that I have home edition. In order to install Docker I need Windows Proffessional Edition - and I don't have it ... it's out of my budget.

Anyway, I kept trying to install (via Chocolatey) and I managed it. How do I start it? I can't find the command in the documentation.

I am having this code:

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

var client = new EventStoreClient(settings);

taken from here.

I am gettig an error "Error starting gRPC call - the connection cannot be created".

I suspect that I need to start the server. But how? even if I am using docker, I would still be unable to start the server with a command line, as I my experience tells me that I would do in these kind of situations.

I would gladely contact their support, however I am just exploring - I do not have a licence for this software.

like image 233
Liviu Sosu Avatar asked Dec 09 '20 21:12

Liviu Sosu


2 Answers

For GRPC download the zip file from https://www.eventstore.com/downloads and unzip into a local folder or install eventstore-oss from choco

for version 20.10 run EventStore.ClusterNode.exe --insecure --run-projections=all --start-standard-projections --enable-atom-pub-over-http

Open localhost:2113 in a browser and confirm the db is running

Use connection string esdb://localhost:2113?Tls=false for gRPC clients. .net 3.1 console app

es-connect.csproj file

<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>

main.cs file

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();
            }

        }
    }
}

browse to http://localhost:2113/web/index.html#/streams to confirm the written stream(s).
Click the links for the stream details e.g. http://localhost:2113/web/index.html#/streams/item-{item id}
and http://localhost:2113/web/index.html#/streams/item-{item id}\0 for the first event

the item category is at http://localhost:2113/web/index.html#/streams/$ce-item
the ItemCreated events at http://localhost:2113/web/index.html#/streams/$et-ItemCreated
the ItemChanged events at http://localhost:2113/web/index.html#/streams/$et-ItemChanged

like image 144
CCondron Avatar answered Oct 17 '22 03:10

CCondron


Once it's been installed via chocolatey you can use the following command to start EventStoreDB

EventStore.ClusterNode.exe --db ./db --log ./logs

However, if you are wanting to access it over HTTP (as in your sample) then you will need to also need to add the --insecure flag

EventStore.ClusterNode.exe --db ./db --log ./logs --insecure
like image 25
mat-mcloughlin Avatar answered Oct 17 '22 03:10

mat-mcloughlin