gateway

package
v0.0.0-...-0490640 Latest Latest
Warning

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

Go to latest
Published: May 16, 2019 License: Apache-2.0 Imports: 19 Imported by: 0

Documentation

Overview

Package gateway is a reverse proxy.

It translates gRPC into RESTful JSON APIs.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func RegisterGatewayHandler

func RegisterGatewayHandler(ctx context.Context, mux *runtime.ServeMux, conn *grpc.ClientConn) error

RegisterGatewayHandler registers the http handlers for service Gateway to "mux". The handlers forward requests to the grpc endpoint over "conn".

func RegisterGatewayHandlerClient

func RegisterGatewayHandlerClient(ctx context.Context, mux *runtime.ServeMux, client GatewayClient) error

RegisterGatewayHandlerClient registers the http handlers for service Gateway to "mux". The handlers forward requests to the grpc endpoint over the given implementation of "GatewayClient". Note: the gRPC framework executes interceptors within the gRPC handler. If the passed in "GatewayClient" doesn't go through the normal gRPC flow (creating a gRPC client etc.) then it will be up to the passed in "GatewayClient" to call the correct interceptors.

func RegisterGatewayHandlerFromEndpoint

func RegisterGatewayHandlerFromEndpoint(ctx context.Context, mux *runtime.ServeMux, endpoint string, opts []grpc.DialOption) (err error)

RegisterGatewayHandlerFromEndpoint is same as RegisterGatewayHandler but automatically dials to "endpoint" and closes the connection when "ctx" gets done.

func RegisterGatewayServer

func RegisterGatewayServer(s *grpc.Server, srv GatewayServer)

Types

type GatewayClient

type GatewayClient interface {
	GetVersion(ctx context.Context, in *empty.Empty, opts ...grpc.CallOption) (*Version, error)
	GetHealth(ctx context.Context, in *empty.Empty, opts ...grpc.CallOption) (*Health, error)
}

GatewayClient is the client API for Gateway service.

For semantics around ctx use and closing/ending streaming RPCs, please refer to https://godoc.org/google.golang.org/grpc#ClientConn.NewStream.

func NewGatewayClient

func NewGatewayClient(cc *grpc.ClientConn) GatewayClient

type GatewayServer

type GatewayServer interface {
	GetVersion(context.Context, *empty.Empty) (*Version, error)
	GetHealth(context.Context, *empty.Empty) (*Health, error)
}

GatewayServer is the server API for Gateway service.

type GatewayServerMock

type GatewayServerMock struct {
	GetVersionFunc func(context.Context, *empty.Empty) (*Version, error)
	GetHealthFunc  func(context.Context, *empty.Empty) (*Health, error)
	// contains filtered or unexported fields
}

GatewayServerMock is the mock-what-you-want struct that stubs all not-overridden methods with "not implemented" returns

func NewGatewayServerMock

func NewGatewayServerMock() *GatewayServerMock

NewGatewayServerMock gives you a fresh instance of GatewayServerMock.

func NewGatewayServerMockWithoutValidation

func NewGatewayServerMockWithoutValidation() *GatewayServerMock

NewGatewayServerMockWithoutValidation gives you a fresh instance of GatewayServerMock which does not attempt to validate requests before passing them to their respective '*Func'.

func (*GatewayServerMock) GetHealth

func (m *GatewayServerMock) GetHealth(ctx context.Context, req *empty.Empty) (*Health, error)

func (*GatewayServerMock) GetVersion

func (m *GatewayServerMock) GetVersion(ctx context.Context, req *empty.Empty) (*Version, error)

func (*GatewayServerMock) Reset

func (m *GatewayServerMock) Reset()

Reset resets all overridden functions

type Health

type Health struct {
	Status               string   `protobuf:"bytes,1,opt,name=status,proto3" json:"status,omitempty"`
	XXX_NoUnkeyedLiteral struct{} `json:"-"`
	XXX_unrecognized     []byte   `json:"-"`
	XXX_sizecache        int32    `json:"-"`
}

Health message

The automate-gateway service health is constructed with:

  • Status: => ok: Everything is alright => initialization: The service is in its initialization process => warning: Something might be wrong? => critical: Something is wrong!

@afiune: Here we can add more health information to the response

func (*Health) Descriptor

func (*Health) Descriptor() ([]byte, []int)

func (*Health) GetStatus

func (m *Health) GetStatus() string

func (*Health) ProtoMessage

func (*Health) ProtoMessage()

func (*Health) Reset

func (m *Health) Reset()

func (*Health) String

func (m *Health) String() string

func (*Health) XXX_DiscardUnknown

func (m *Health) XXX_DiscardUnknown()

func (*Health) XXX_Marshal

func (m *Health) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*Health) XXX_Merge

func (dst *Health) XXX_Merge(src proto.Message)

func (*Health) XXX_Size

func (m *Health) XXX_Size() int

func (*Health) XXX_Unmarshal

func (m *Health) XXX_Unmarshal(b []byte) error

type Version

type Version struct {
	Version              string   `protobuf:"bytes,2,opt,name=version,proto3" json:"version,omitempty"`
	Built                string   `protobuf:"bytes,1,opt,name=built,proto3" json:"built,omitempty"`
	Name                 string   `protobuf:"bytes,3,opt,name=name,proto3" json:"name,omitempty"`
	Sha                  string   `protobuf:"bytes,4,opt,name=sha,proto3" json:"sha,omitempty"`
	XXX_NoUnkeyedLiteral struct{} `json:"-"`
	XXX_unrecognized     []byte   `json:"-"`
	XXX_sizecache        int32    `json:"-"`
}

Version message

The service version constructed with: * Service name * Built time * Semantic version * Git SHA

func (*Version) Descriptor

func (*Version) Descriptor() ([]byte, []int)

func (*Version) GetBuilt

func (m *Version) GetBuilt() string

func (*Version) GetName

func (m *Version) GetName() string

func (*Version) GetSha

func (m *Version) GetSha() string

func (*Version) GetVersion

func (m *Version) GetVersion() string

func (*Version) ProtoMessage

func (*Version) ProtoMessage()

func (*Version) Reset

func (m *Version) Reset()

func (*Version) String

func (m *Version) String() string

func (*Version) XXX_DiscardUnknown

func (m *Version) XXX_DiscardUnknown()

func (*Version) XXX_Marshal

func (m *Version) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*Version) XXX_Merge

func (dst *Version) XXX_Merge(src proto.Message)

func (*Version) XXX_Size

func (m *Version) XXX_Size() int

func (*Version) XXX_Unmarshal

func (m *Version) XXX_Unmarshal(b []byte) error

Jump to

Keyboard shortcuts

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