counter

package
v0.0.0-...-9a37cb8 Latest Latest
Warning

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

Go to latest
Published: Feb 27, 2023 License: MIT Imports: 15 Imported by: 0

Documentation

Overview

Package counter is a reverse proxy.

It translates gRPC into RESTful JSON APIs.

Index

Constants

This section is empty.

Variables

View Source
var Counter_ServiceDesc = grpc.ServiceDesc{
	ServiceName: "counter.Counter",
	HandlerType: (*CounterServer)(nil),
	Methods: []grpc.MethodDesc{
		{
			MethodName: "AddDomain",
			Handler:    _Counter_AddDomain_Handler,
		},
		{
			MethodName: "RemoveDomain",
			Handler:    _Counter_RemoveDomain_Handler,
		},
		{
			MethodName: "GetStat",
			Handler:    _Counter_GetStat_Handler,
		},
	},
	Streams:  []grpc.StreamDesc{},
	Metadata: "counter/counter.proto",
}

Counter_ServiceDesc is the grpc.ServiceDesc for Counter service. It's only intended for direct use with grpc.RegisterService, and not to be introspected or modified (even as a copy)

View Source
var File_counter_counter_proto protoreflect.FileDescriptor

Functions

func RegisterCounterHandler

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

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

func RegisterCounterHandlerClient

func RegisterCounterHandlerClient(ctx context.Context, mux *runtime.ServeMux, client CounterClient) error

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

func RegisterCounterHandlerFromEndpoint

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

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

func RegisterCounterHandlerServer

func RegisterCounterHandlerServer(ctx context.Context, mux *runtime.ServeMux, server CounterServer) error

RegisterCounterHandlerServer registers the http handlers for service Counter to "mux". UnaryRPC :call CounterServer directly. StreamingRPC :currently unsupported pending https://github.com/grpc/grpc-go/issues/906. Note that using this registration option will cause many gRPC library features to stop working. Consider using RegisterCounterHandlerFromEndpoint instead.

func RegisterCounterServer

func RegisterCounterServer(s grpc.ServiceRegistrar, srv CounterServer)

Types

type CounterClient

type CounterClient interface {
	// Adding domain to service
	AddDomain(ctx context.Context, in *Domain, opts ...grpc.CallOption) (*Response, error)
	// Remove domain from service
	RemoveDomain(ctx context.Context, in *Domain, opts ...grpc.CallOption) (*Response, error)
	// Get stats from domain
	GetStat(ctx context.Context, in *Domain, opts ...grpc.CallOption) (*Stats, error)
}

CounterClient is the client API for Counter service.

For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream.

func NewCounterClient

func NewCounterClient(cc grpc.ClientConnInterface) CounterClient

type CounterServer

type CounterServer interface {
	// Adding domain to service
	AddDomain(context.Context, *Domain) (*Response, error)
	// Remove domain from service
	RemoveDomain(context.Context, *Domain) (*Response, error)
	// Get stats from domain
	GetStat(context.Context, *Domain) (*Stats, error)
	// contains filtered or unexported methods
}

CounterServer is the server API for Counter service. All implementations must embed UnimplementedCounterServer for forward compatibility

type Domain

type Domain struct {
	Domain string `protobuf:"bytes,1,opt,name=domain,proto3" json:"domain,omitempty"`
	// contains filtered or unexported fields
}

func (*Domain) Descriptor deprecated

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

Deprecated: Use Domain.ProtoReflect.Descriptor instead.

func (*Domain) GetDomain

func (x *Domain) GetDomain() string

func (*Domain) ProtoMessage

func (*Domain) ProtoMessage()

func (*Domain) ProtoReflect

func (x *Domain) ProtoReflect() protoreflect.Message

func (*Domain) Reset

func (x *Domain) Reset()

func (*Domain) String

func (x *Domain) String() string

type Response

type Response struct {
	Status string `protobuf:"bytes,1,opt,name=status,proto3" json:"status,omitempty"`
	// contains filtered or unexported fields
}

func (*Response) Descriptor deprecated

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

Deprecated: Use Response.ProtoReflect.Descriptor instead.

func (*Response) GetStatus

func (x *Response) GetStatus() string

func (*Response) ProtoMessage

func (*Response) ProtoMessage()

func (*Response) ProtoReflect

func (x *Response) ProtoReflect() protoreflect.Message

func (*Response) Reset

func (x *Response) Reset()

func (*Response) String

func (x *Response) String() string

type Stats

type Stats struct {
	Cnt int64 `protobuf:"varint,1,opt,name=cnt,proto3" json:"cnt,omitempty"`
	// contains filtered or unexported fields
}

func (*Stats) Descriptor deprecated

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

Deprecated: Use Stats.ProtoReflect.Descriptor instead.

func (*Stats) GetCnt

func (x *Stats) GetCnt() int64

func (*Stats) ProtoMessage

func (*Stats) ProtoMessage()

func (*Stats) ProtoReflect

func (x *Stats) ProtoReflect() protoreflect.Message

func (*Stats) Reset

func (x *Stats) Reset()

func (*Stats) String

func (x *Stats) String() string

type UnimplementedCounterServer

type UnimplementedCounterServer struct {
}

UnimplementedCounterServer must be embedded to have forward compatible implementations.

func (UnimplementedCounterServer) AddDomain

func (UnimplementedCounterServer) GetStat

func (UnimplementedCounterServer) RemoveDomain

type UnsafeCounterServer

type UnsafeCounterServer interface {
	// contains filtered or unexported methods
}

UnsafeCounterServer may be embedded to opt out of forward compatibility for this service. Use of this interface is not recommended, as added methods to CounterServer will result in compilation errors.

Jump to

Keyboard shortcuts

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