Skip to content

Commit c9f752a

Browse files
committed
exposes metrics, registration and store apis in GarnetApplication
1 parent 05cb522 commit c9f752a

File tree

2 files changed

+21
-2
lines changed

2 files changed

+21
-2
lines changed

libs/host/GarnetApplicatrion.cs

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,17 +6,34 @@
66
using System.Threading.Tasks;
77
using Garnet.common;
88
using Garnet.server;
9+
using Microsoft.Extensions.DependencyInjection;
910
using Microsoft.Extensions.Hosting;
1011

1112
namespace Garnet;
1213

1314
public class GarnetApplication : IHost
1415
{
16+
public MetricsApi Metrics
17+
{
18+
get
19+
{
20+
return host.Services.GetRequiredService<MetricsApi>();
21+
}
22+
}
23+
1524
public RegisterApi Register
1625
{
1726
get
1827
{
19-
throw new NotImplementedException();
28+
return host.Services.GetRequiredService<RegisterApi>();
29+
}
30+
}
31+
32+
public StoreApi Store
33+
{
34+
get
35+
{
36+
return host.Services.GetRequiredService<StoreApi>();
2037
}
2138
}
2239

main/GarnetServer/Program.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,16 @@
88

99
var app = builder.Build();
1010

11+
RegisterExtensions(app);
12+
1113
app.Run();
1214

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

0 commit comments

Comments
 (0)