Skip to content

Commit

Permalink
exposes metrics, registration and store apis in GarnetApplication
Browse files Browse the repository at this point in the history
  • Loading branch information
s3w3nofficial committed Jan 23, 2025
1 parent 05cb522 commit c9f752a
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 2 deletions.
19 changes: 18 additions & 1 deletion libs/host/GarnetApplicatrion.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,34 @@
using System.Threading.Tasks;
using Garnet.common;
using Garnet.server;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;

namespace Garnet;

public class GarnetApplication : IHost
{
public MetricsApi Metrics
{
get
{
return host.Services.GetRequiredService<MetricsApi>();
}
}

public RegisterApi Register
{
get
{
throw new NotImplementedException();
return host.Services.GetRequiredService<RegisterApi>();
}
}

public StoreApi Store
{
get
{
return host.Services.GetRequiredService<StoreApi>();
}
}

Expand Down
4 changes: 3 additions & 1 deletion main/GarnetServer/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,16 @@

var app = builder.Build();

RegisterExtensions(app);

app.Run();

/// <summary>
/// Register new commands with the server. You can access these commands from clients using
/// commands such as db.Execute in StackExchange.Redis. Example:
/// db.Execute("SETIFPM", key, value, prefix);
/// </summary>
static void RegisterExtensions(GarnetServer server)
static void RegisterExtensions(GarnetApplication server)
{
// Register custom command on raw strings (SETIFPM = "set if prefix match")
// Add RESP command info to registration for command to appear when client runs COMMAND / COMMAND INFO
Expand Down

0 comments on commit c9f752a

Please sign in to comment.