Giter VIP home page Giter VIP logo

grpcinjection's Introduction

Grpc Injection

A Source Generator package for C#, that allow you to generate Grpc Services and Interceptors dependencies without Reflection.

Build License

Installing

The package is available (on NuGet. To install from the command line:

dotnet add package GrpcInjection

Or use the Package Manager in Visual Studio.

Setup Service Provider

Only add in your Startup or Program for use this package, like so:

   public void ConfigureServices(IServiceCollection services)
        {
            services.AddGrpcInject();
        }

        public void Configure(IApplicationBuilder app)
        {
            app.UseGrpcInject();
        }

Inject one Service Grpc

Only add an attribute to the classes Grpc Service that you want injected in your service provider, like so:

    [GrpcService]
    public class GreeterService : Greeter.GreeterBase
    {
        private readonly ILogger<GreeterService> _logger;
        public GreeterService(ILogger<GreeterService> logger)
        {
            
            _logger = logger;
        }

        public override Task<HelloReply> SayHello(HelloRequest request, ServerCallContext context)
        {
            return Task.FromResult(new HelloReply
            {
                Message = "Hello " + request.Name
            });
        }
    }

Inject one Interceptor Grpc

Only add an attribute to the classes Grpc Interceptors that you want injected in your service provider, like so:

    [GrpcInterceptor]
    public class LogInterceptor : Interceptor
    {
        private readonly ILogger<LogInterceptor> _logger;
        public LogInterceptor(ILogger<LogInterceptor> logger) => _logger = logger;

    }

Contributing

The main supported IDE for development is Visual Studio 2022.

Questions, comments, bug reports, and pull requests are all welcome. Bug reports that include steps to reproduce (including code) are preferred. Even better, make them in the form of pull requests. Before you start to work on an existing issue, check if it is not assigned to anyone yet, and if it is, talk to that person.

Maintainers/Core team

Contributors can be found at the contributors page on Github.

License

This software is open source, licensed under the MIT License. See LICENSE for details. Check out the terms of the license before you contribute, fork, copy or do anything with the code. If you decide to contribute you agree to grant copyright of all your contribution to this project and agree to mention clearly if do not agree to these terms. Your work will be licensed with the project at MIT, along the rest of the code.

grpcinjection's People

Contributors

juniorporfirio avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.