keepalive

package
v1.1.26 Latest Latest
Warning

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

Go to latest
Published: Dec 11, 2024 License: MIT Imports: 4 Imported by: 0

README

keepalive

Example of use

grpc server
func getServerOptions() []grpc.ServerOption {
	var options []grpc.ServerOption
	options = append(options, keepalive.ServerKeepAlive()...)

	return options
}

func main() {
	server := grpc.NewServer(getServerOptions()...)

	list, err := net.Listen("tcp", addr)
	if err != nil {
		panic(err)
	}

    // ......
}

grpc client
func getDialOptions() []grpc.DialOption {
	var options []grpc.DialOption

	// use insecure transfer
	options = append(options, grpc.WithTransportCredentials(insecure.NewCredentials()))

	// keepalive option
	options = append(options, keepalive.ClientKeepAlive())

	return options
}

func main() {
	conn, err := grpc.Dial("127.0.0.1:8080", getDialOptions()...)
	if err != nil {
		panic(err)
	}

	// ......
}

Documentation

Overview

Package keepalive is setting grpc keepalive parameters.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ClientKeepAlive

func ClientKeepAlive() grpc.DialOption

ClientKeepAlive keep the connection set

func ServerKeepAlive

func ServerKeepAlive() []grpc.ServerOption

ServerKeepAlive keep the connection set

Types

This section is empty.

Jump to

Keyboard shortcuts

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