-
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #14 from mizrael/memory
updated memory watcher
- Loading branch information
Showing
11 changed files
with
126 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
namespace EvenireDB.Server.DTO; | ||
|
||
public record ApiError(int Code, string Message); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,2 @@ | ||
namespace EvenireDB.Server.DTO | ||
{ | ||
public record EventDataDTO(string Type, ReadOnlyMemory<byte> Data); | ||
} | ||
namespace EvenireDB.Server.DTO; | ||
public record EventDataDTO(string Type, ReadOnlyMemory<byte> Data); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
18 changes: 18 additions & 0 deletions
18
src/tools/EvenireDB.Tools.EventsGenerator/EvenireDB.Tools.EventsGenerator.csproj
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
|
||
<PropertyGroup> | ||
<OutputType>Exe</OutputType> | ||
<TargetFramework>net8.0</TargetFramework> | ||
<ImplicitUsings>enable</ImplicitUsings> | ||
<Nullable>enable</Nullable> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<ProjectReference Include="..\..\EvenireDB.Client\EvenireDB.Client.csproj" /> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<PackageReference Include="System.CommandLine" Version="2.0.0-beta4.22272.1" /> | ||
</ItemGroup> | ||
|
||
</Project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
using EvenireDB.Client; | ||
using Microsoft.Extensions.DependencyInjection; | ||
using System.CommandLine; | ||
using System.Text; | ||
|
||
var defaultServerUri = new Uri("http://localhost:5001"); | ||
var defaultEventsCount = 100; | ||
|
||
var serverOption = new Option<Uri>( | ||
name: "--server", | ||
getDefaultValue: () => defaultServerUri, | ||
description: $"The server uri. Defaults to {defaultServerUri}."); | ||
var useGrpc = new Option<bool>( | ||
name: "--grpc", | ||
description: "Use gRPC instead of HTTP. Defaults to false."); | ||
var eventsCount = new Option<int>( | ||
name: "--count", | ||
getDefaultValue: () => defaultEventsCount, | ||
description: $"Count of events to send. Defaults to {defaultEventsCount}."); | ||
|
||
var streamIdOption = new Option<Guid>( | ||
name: "--stream", | ||
description: "The stream to use."); | ||
|
||
|
||
var rootCommand = new RootCommand | ||
{ | ||
serverOption, | ||
useGrpc, | ||
eventsCount, | ||
streamIdOption | ||
}; | ||
rootCommand.SetHandler(async (streamId, uri, useGrpc, eventsCount) => { | ||
var services = new ServiceCollection(); | ||
services.AddEvenireDB(new EvenireConfig(uri, useGrpc)); | ||
|
||
var provider = services.BuildServiceProvider(); | ||
var client = provider.GetRequiredService<IEventsClient>(); | ||
|
||
Console.ForegroundColor = ConsoleColor.Yellow; | ||
Console.WriteLine($"Sending {eventsCount} events to stream '{streamId}' on server '{uri}'..."); | ||
|
||
var events = Enumerable.Range(0, eventsCount).Select(i => new EventData($"event-{i}", Encoding.UTF8.GetBytes($"event-{i}"))).ToArray(); | ||
|
||
try | ||
{ | ||
await client.AppendAsync(streamId, events); | ||
} | ||
catch (ClientException cliEx) | ||
{ | ||
Console.ForegroundColor = ConsoleColor.Red; | ||
Console.WriteLine("an error has occurred while sending events: " + cliEx.Message); | ||
} | ||
|
||
Console.ForegroundColor = ConsoleColor.Green; | ||
Console.WriteLine("Done."); | ||
|
||
Console.ResetColor(); | ||
}, streamIdOption, serverOption, useGrpc, eventsCount); | ||
|
||
await rootCommand.InvokeAsync(args); |