grpc

package
v3.8.6 Latest Latest
Warning

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

Go to latest
Published: Apr 1, 2022 License: Apache-2.0 Imports: 46 Imported by: 0

README

GRPC Server

The grpc server is a micro.Server compatible server.

Overview

The server makes use of the google.golang.org/grpc framework for the underlying server but continues to use micro handler signatures and protoc-gen-micro generated code.

Usage

Specify the server to your micro service

import (
        "github.com/micro/go-micro"
        "github.com/micro/go-plugins/server/grpc"
)

func main() {
        service := micro.NewService(
                // This needs to be first as it replaces the underlying server
                // which causes any configuration set before it
                // to be discarded
                micro.Server(grpc.NewServer()),
                micro.Name("greeter"),
        )
}

NOTE: Setting the gRPC server and/or client causes the underlying the server/client to be replaced which causes any previous configuration set on that server/client to be discarded. It is therefore recommended to set gRPC server/client before any other configuration

Documentation

Overview

Package grpc provides a grpc server

Index

Constants

This section is empty.

Variables

View Source
var (
	// DefaultMaxRecvMsgSize maximum message that client can receive
	// (16 MB).
	DefaultMaxRecvMsgSize = 1024 * 1024 * 16

	// DefaultMaxSendMsgSize maximum message that client can send
	// (16 MB).
	DefaultMaxSendMsgSize = 1024 * 1024 * 16
)

Functions

func AuthTLS

func AuthTLS(t *tls.Config) server.Option

AuthTLS should be used to setup a secure authentication using TLS

func Codec

func Codec(contentType string, c encoding.Codec) server.Option

gRPC Codec to be used to encode/decode requests for a given content type

func GRPCWebOptions

func GRPCWebOptions(opts ...grpcweb.Option) server.Option

GRPCWebOptions to be used to start a gRPC Web server

func GRPCWebPort

func GRPCWebPort(addr string) server.Option

GRPCWebPort to be used to start a gRPC Web server

func Listener

func Listener(l net.Listener) server.Option

Listener specifies the net.Listener to use instead of the default

func MaxConn

func MaxConn(n int) server.Option

MaxConn specifies maximum number of max simultaneous connections to server

func MaxMsgSize deprecated

func MaxMsgSize(s int) server.Option

Deprecated: use MaxRecvMsgSize or MaxSendMsgSize instead MaxMsgSize set the maximum message in bytes the server can receive and send. Default maximum message size is 4 MB.

func MaxRecvMsgSize

func MaxRecvMsgSize(s int) server.Option

MaxRecvMsgSize set the maximum size of message that server can receive.

func MaxSendMsgSize

func MaxSendMsgSize(s int) server.Option

MaxSendMsgSize set the maximum size of message that server can send.

func NewServer

func NewServer(opts ...server.Option) server.Server

func Options

func Options(opts ...grpc.ServerOption) server.Option

Options to be used to configure gRPC options

func ServiceFromMethod

func ServiceFromMethod(m string) string

ServiceFromMethod returns the service /service.Foo/Bar => service

func ServiceMethod

func ServiceMethod(m string) (string, string, error)

ServiceMethod converts a gRPC method to a Go method Input: Foo.Bar, /Foo/Bar, /package.Foo/Bar, /a.package.Foo/Bar Output: [Foo, Bar]

Types

This section is empty.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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