Skip to content

Instantly share code, notes, and snippets.

@tocalai tocalai/App.cs
Created Jul 12, 2019

Embed
What would you like to do?
Class for start and initial Grpc service instance
public class App
{
private readonly Grpc.Core.Server _serverInstance;
public App(string host, int port, params ServerServiceDefinition[] services)
{
_serverInstance = new Grpc.Core.Server
{
Ports =
{
new ServerPort(host, port, ServerCredentials.Insecure)
}
};
InitialAndStartServices(services);
}
private void InitialAndStartServices(ServerServiceDefinition[] services)
{
services.ToList().ForEach(srv =>
{
_serverInstance.Services.Add(srv);
});
_serverInstance.Start();
Console.WriteLine($"Server listening on host = {_serverInstance.Ports.First().Host}, port = {_serverInstance.Ports.First().Port}");
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.