server

package
v1.1.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 14, 2024 License: MIT Imports: 5 Imported by: 0

README

grpc server

Generic grpc server.

Example of use

	import "github.com/18721889353/sunshine/pkg/grpc/server"

	port := 8282
	registerFn := func(s *grpc.Server) {
		pb.RegisterGreeterServer(s, &greeterServer{})
	}
	
	server.Run(port, registerFn,
		//server.WithSecure(credentials),
		//server.WithUnaryInterceptor(unaryInterceptors...),
		//server.WithStreamInterceptor(streamInterceptors...),
		//server.WithServiceRegister(func() {}),
	)

	select{}

Examples of practical use https://github.com/18721889353/grpc_examples/blob/main/usage/server/main.go

Documentation

Overview

Package server is generic grpc server-side.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Run

func Run(port int, registerFn RegisterFn, options ...Option)

Run grpc server

Types

type Option

type Option func(*options)

Option set server option

func WithSecure

func WithSecure(credential credentials.TransportCredentials) Option

WithSecure set secure

func WithServiceRegister

func WithServiceRegister(fn ServiceRegisterFn) Option

WithServiceRegister set service register

func WithStreamInterceptor

func WithStreamInterceptor(interceptors ...grpc.StreamServerInterceptor) Option

WithStreamInterceptor set stream interceptor

func WithUnaryInterceptor

func WithUnaryInterceptor(interceptors ...grpc.UnaryServerInterceptor) Option

WithUnaryInterceptor set unary interceptor

type RegisterFn

type RegisterFn func(srv *grpc.Server)

RegisterFn register object

type ServiceRegisterFn

type ServiceRegisterFn func()

ServiceRegisterFn service register

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL