grpcserver

package
v8.0.0+incompatible Latest Latest
Warning

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

Go to latest
Published: Apr 24, 2019 License: Apache-2.0 Imports: 13 Imported by: 53

Documentation

Overview

Package grpcserver is a generic gRPC server manager Copyright 2018 Portworx

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Copyright 2017 The Kubernetes Authors.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Package grpcserver is a generic gRPC server manager Copyright 2018 Portworx

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddMetadataToContext

func AddMetadataToContext(ctx context.Context, k, v string) context.Context

func Connect

func Connect(address string, dialOptions []grpc.DialOption) (*grpc.ClientConn, error)

Connect address by grpc

func GetMetadataValueFromKey

func GetMetadataValueFromKey(ctx context.Context, k string) string

Types

type GrpcServer

type GrpcServer struct {
	// contains filtered or unexported fields
}

GrpcServer is a server manager for gRPC implementations

func New

func New(config *GrpcServerConfig) (*GrpcServer, error)

New creates a gRPC server on the specified port and transport.

func (*GrpcServer) Address

func (s *GrpcServer) Address() string

Address returns the address of the server which can be used by clients to connect.

func (*GrpcServer) IsRunning

func (s *GrpcServer) IsRunning() bool

IsRunning returns true if the server is currently running

func (*GrpcServer) Start

func (s *GrpcServer) Start(register func(grpcServer *grpc.Server)) error

Start is used to start the server. It will return an error if the server is already runnig.

func (*GrpcServer) StartWithServer

func (s *GrpcServer) StartWithServer(server func() *grpc.Server) error

StartWithServer is used to start the server. It will return an error if the server is already runnig.

func (*GrpcServer) Stop

func (s *GrpcServer) Stop()

Stop is used to stop the gRPC server. It can be called multiple times. It does nothing if the server has already been stopped.

type GrpcServerConfig

type GrpcServerConfig struct {
	Name    string
	Net     string
	Address string
}

GrpcServerConfig provides the configuration to the the gRPC server created by NewGrpcServer()

type Server

type Server interface {
	// Start the server. If called on a running server it will return an error.
	Start() error

	// Stop the server. If called on a stopped server it will have no effect
	Stop()

	// IsRunning tell the caller if the server is currently running
	IsRunning() bool

	// Address returns the address used by clients to connect to the server
	Address() string
}

Server is an interface to a gRPC server which provides an implementation of an exported gRPC interface

Jump to

Keyboard shortcuts

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