Documentation ¶
Index ¶
- type ServiceProxy
- func (f *ServiceProxy) AddConn(service string, clientConn *grpc.ClientConn, allowedMethods ...string) error
- func (f *ServiceProxy) ForwardServerStreamRequest(ctx context.Context, stream grpc.ServerStream, info *grpc.StreamServerInfo) error
- func (f *ServiceProxy) ForwardUnaryRequest(ctx context.Context, req any, info *grpc.UnaryServerInfo) (any, error)
- func (f *ServiceProxy) IsAllowedMethod(fullMethod string) bool
- func (f *ServiceProxy) RemoveConn(service string)
- func (f *ServiceProxy) RevokeMethod(method string)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ServiceProxy ¶
type ServiceProxy struct {
// contains filtered or unexported fields
}
ServiceProxy is a gRPC service proxy that forwards requests to other services
func NewServiceProxy ¶
func NewServiceProxy() *ServiceProxy
NewServiceProxy creates a new ServiceProxy
func (*ServiceProxy) AddConn ¶
func (f *ServiceProxy) AddConn(service string, clientConn *grpc.ClientConn, allowedMethods ...string) error
AddConn adds a connection to the service proxy.
allowedMethods can be passed to restrict the methods that can be proxied. For example, to allow only the method "ExampleMethod" in the service "Service" and package "org.product.v1":
AddConn("org.product.v1.Service", clientConn, "org.product.v1.Service/ExampleMethod")
To allow all methods in the service "Service" and package "org.product.v1":
AddConn("org.product.v1.Service", clientConn, "org.product.v1.Service/*")
If no methods are provided, all methods in the service will be allowed.
func (*ServiceProxy) ForwardServerStreamRequest ¶ added in v0.0.9
func (f *ServiceProxy) ForwardServerStreamRequest(ctx context.Context, stream grpc.ServerStream, info *grpc.StreamServerInfo) error
ForwardServerStreamRequest forwards a server streaming request to the appropriate service.
func (*ServiceProxy) ForwardUnaryRequest ¶
func (f *ServiceProxy) ForwardUnaryRequest(ctx context.Context, req any, info *grpc.UnaryServerInfo) (any, error)
ForwardUnaryRequest forwards a unary request to the appropriate service.
func (*ServiceProxy) IsAllowedMethod ¶
func (f *ServiceProxy) IsAllowedMethod(fullMethod string) bool
IsAllowedMethod checks if a method is allowed to be proxied
func (*ServiceProxy) RemoveConn ¶
func (f *ServiceProxy) RemoveConn(service string)
RemoveConn removes a connection from the service proxy
func (*ServiceProxy) RevokeMethod ¶
func (f *ServiceProxy) RevokeMethod(method string)
RevokeMethod revokes a method from the service proxy