Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/nhatthm/go-grpc-middleware

gRPC Go Middleware: interceptors, helpers, utilities
https://github.com/nhatthm/go-grpc-middleware

go golang grpc helper interceptor middleware utilities

Last synced: 22 days ago
JSON representation

gRPC Go Middleware: interceptors, helpers, utilities

Awesome Lists containing this project

README

        

# Go gRPC Middleware

[![GitHub Releases](https://img.shields.io/github/v/release/nhatthm/go-grpc-middleware)](https://github.com/nhatthm/go-grpc-middleware/releases/latest)
[![Build Status](https://github.com/nhatthm/go-grpc-middleware/actions/workflows/test.yaml/badge.svg)](https://github.com/nhatthm/go-grpc-middleware/actions/workflows/test.yaml)
[![codecov](https://codecov.io/gh/nhatthm/go-grpc-middleware/branch/master/graph/badge.svg?token=eTdAgDE2vR)](https://codecov.io/gh/nhatthm/go-grpc-middleware)
[![Go Report Card](https://goreportcard.com/badge/github.com/nhatthm/go-grpc-middleware)](https://goreportcard.com/report/github.com/nhatthm/go-grpc-middleware)
[![GoDevDoc](https://img.shields.io/badge/dev-doc-00ADD8?logo=go)](https://pkg.go.dev/github.com/nhatthm/go-grpc-middleware)
[![Donate](https://img.shields.io/badge/Donate-PayPal-green.svg)](https://www.paypal.com/donate/?hosted_button_id=PJZSGJN57TDJY)

[gRPC Go](https://github.com/grpc/grpc-go) Middleware: interceptors, helpers, utilities.

## Table of Contents

- [Prerequisites](#prerequisites)
- [Install](#install)
- [Interceptors](#interceptors)
- [Ctxd Logger](#ctxd-logger)
- [Timeout](#timeout)

## Prerequisites

- `Go >= 1.22`

[[table of contents]](#table-of-contents)

## Install

```bash
go get github.com/nhatthm/go-grpc-middleware
```

[[table of contents]](#table-of-contents)

## Interceptors

### Ctxd Logger

See [bool64/ctxd](https://github.com/bool64/ctxd)

- Server middlewares
- `ctxd.UnaryServerInterceptor`
- `ctxd.StreamServerInterceptor`
- Client middlewares
- `ctxd.UnaryClientInterceptor`
- `ctxd.StreamClientInterceptor`

[[table of contents]](#table-of-contents)

### Timeout

There are 4 dial options for gRPC client:

- Sleep for a duration before doing the job.

`timeout.WithStreamClientSleepInterceptor`

`timeout.WithUnaryClientSleepInterceptor`
- Automatically creates a new context with given duration if there is none in the current context.

`timeout.WithStreamClientTimeoutInterceptor`

`timeout.WithUnaryClientTimeoutInterceptor`

## Donation

If this project help you reduce time to develop, you can give me a cup of coffee :)

[[table of contents]](#table-of-contents)

### Paypal donation

[![paypal](https://www.paypalobjects.com/en_US/i/btn/btn_donateCC_LG.gif)](https://www.paypal.com/donate/?hosted_button_id=PJZSGJN57TDJY)

       or scan this

[[table of contents]](#table-of-contents)