service

package
v0.2.6 Latest Latest
Warning

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

Go to latest
Published: Oct 13, 2025 License: MIT Imports: 22 Imported by: 0

Documentation

Overview

Package service contains generated code by adptool.

Package service implements the functions, types, and interfaces for the module.

Index

Constants

View Source
const (
	ProtocolGRPC = "grpc"
	ProtocolHTTP = "http"
)

Protocol is the name of the gRPC, HTTP, or other protocol.

View Source
const DefaultTimeout = 5 * time.Second
View Source
const SupportPackageIsVersion1 = transhttp.SupportPackageIsVersion1

Variables

View Source
var (
	ErrNilServerConfig     = newServiceError("server configuration is nil")
	ErrMissingServerConfig = newServiceError("missing server configuration")

	ErrNilClientConfig     = newServiceError("client configuration is nil")
	ErrMissingClientConfig = newServiceError("missing client configuration")

	ErrMissingProtocol     = newServiceError("protocol is not specified")
	ErrUnsupportedProtocol = newServiceError("unsupported protocol")
)

Predefined errors using the common StructuredError

Functions

func AddressGRPC added in v0.2.6

func AddressGRPC(addr string) transgrpc.ServerOption

func AddressHTTP added in v0.2.6

func AddressHTTP(addr string) transhttp.ServerOption

func CodecForRequestHTTP added in v0.2.6

func CodecForRequestHTTP(r *http.Request, name string) (encoding.Codec, bool)

func CodecForResponseHTTP added in v0.2.6

func CodecForResponseHTTP(r *http.Response) encoding.Codec

func ContentTypeHTTP added in v0.2.6

func ContentTypeHTTP(contentType string) transhttp.CallOption

func CustomHealthGRPC added in v0.2.6

func CustomHealthGRPC() transgrpc.ServerOption

func DefaultErrorDecoderHTTP added in v0.2.6

func DefaultErrorDecoderHTTP(p0 context.Context, res *http.Response) error

func DefaultErrorEncoderHTTP added in v0.2.6

func DefaultErrorEncoderHTTP(w http.ResponseWriter, r *http.Request, err error)

func DefaultRequestDecoderHTTP added in v0.2.6

func DefaultRequestDecoderHTTP(r *http.Request, v any) error

func DefaultRequestEncoderHTTP added in v0.2.6

func DefaultRequestEncoderHTTP(p0 context.Context, contentType string, in any) ([]byte, error)

func DefaultRequestQueryHTTP added in v0.2.6

func DefaultRequestQueryHTTP(r *http.Request, v any) error

func DefaultRequestVarsHTTP added in v0.2.6

func DefaultRequestVarsHTTP(r *http.Request, v any) error

func DefaultResponseDecoderHTTP added in v0.2.6

func DefaultResponseDecoderHTTP(p0 context.Context, res *http.Response, v any) error

func DefaultResponseEncoderHTTP added in v0.2.6

func DefaultResponseEncoderHTTP(w http.ResponseWriter, r *http.Request, v any) error

func DialGRPC added in v0.2.6

func DialGRPC(ctx context.Context, opts ...transgrpc.ClientOption) (*grpc.ClientConn, error)

func DialInsecureGRPC added in v0.2.6

func DialInsecureGRPC(ctx context.Context, opts ...transgrpc.ClientOption) (*grpc.ClientConn, error)

func DisableReflectionGRPC added in v0.2.6

func DisableReflectionGRPC() transgrpc.ServerOption

func EndpointGRPC added in v0.2.6

func EndpointGRPC(endpoint *url.URL) transgrpc.ServerOption

func EndpointHTTP added in v0.2.6

func EndpointHTTP(endpoint *url.URL) transhttp.ServerOption

func ErrorEncoderHTTP added in v0.2.6

func ErrorEncoderHTTP(en transhttp.EncodeErrorFunc) transhttp.ServerOption

func FilterChainHTTP added in v0.2.6

func FilterChainHTTP(filters ...transhttp.FilterFunc) transhttp.FilterFunc

func FilterHTTP added in v0.2.6

func FilterHTTP(filters ...transhttp.FilterFunc) transhttp.ServerOption

func GetStreamGRPC added in v0.2.6

func GetStreamGRPC(ctx context.Context) grpc.ServerStream

func HeaderHTTP added in v0.2.6

func HeaderHTTP(header *http.Header) transhttp.CallOption

func ListenerGRPC added in v0.2.6

func ListenerGRPC(lis net.Listener) transgrpc.ServerOption

func ListenerHTTP added in v0.2.6

func ListenerHTTP(lis net.Listener) transhttp.ServerOption

func LoggerGRPC added in v0.2.6

func LoggerGRPC(p0 log.Logger) transgrpc.ServerOption

func LoggerHTTP added in v0.2.6

func LoggerHTTP(p0 log.Logger) transhttp.ServerOption

func MethodNotAllowedHandlerHTTP added in v0.2.6

func MethodNotAllowedHandlerHTTP(handler http.Handler) transhttp.ServerOption

func MiddlewareGRPC added in v0.2.6

func MiddlewareGRPC(m ...middleware.Middleware) transgrpc.ServerOption

func MiddlewareHTTP added in v0.2.6

func MiddlewareHTTP(m ...middleware.Middleware) transhttp.ServerOption

func NetworkGRPC added in v0.2.6

func NetworkGRPC(network string) transgrpc.ServerOption

func NetworkHTTP added in v0.2.6

func NetworkHTTP(network string) transhttp.ServerOption

func NewClient added in v0.2.6

func NewClient(ctx context.Context, cfg *transportv1.Client, opts ...options.Option) (interfaces.Client, error)

NewClient creates a new client instance based on the provided configuration and options.

func NewClientHTTP added in v0.2.6

func NewClientHTTP(ctx context.Context, opts ...transhttp.ClientOption) (*transhttp.Client, error)

func NewRedirectHTTP added in v0.2.6

func NewRedirectHTTP(url string, code int) transhttp.Redirector

func NewServer added in v0.2.6

func NewServer(cfg *transportv1.Server, opts ...options.Option) (interfaces.Server, error)

NewServer creates a new server instance based on the provided configuration and options. It automatically looks up the appropriate protocol factory from the default registry.

func NewServerGRPC added in v0.2.6

func NewServerGRPC(opts ...transgrpc.ServerOption) *transgrpc.Server

func NewServerHTTP added in v0.2.6

func NewServerHTTP(opts ...transhttp.ServerOption) *transhttp.Server

func NotFoundHandlerHTTP added in v0.2.6

func NotFoundHandlerHTTP(handler http.Handler) transhttp.ServerOption

func OperationHTTP added in v0.2.6

func OperationHTTP(operation string) transhttp.CallOption

func OptionsGRPC added in v0.2.6

func OptionsGRPC(opts ...grpc.ServerOption) transgrpc.ServerOption

func PathPrefixHTTP added in v0.2.6

func PathPrefixHTTP(prefix string) transhttp.ServerOption

func PathTemplateHTTP added in v0.2.6

func PathTemplateHTTP(pattern string) transhttp.CallOption

func RegisterProtocol added in v0.2.6

func RegisterProtocol(name string, f ProtocolFactory)

RegisterProtocol registers a new protocol factory with the default registry. This function is the public API for registration and is safe for concurrent use.

func RequestDecoderHTTP added in v0.2.6

func RequestDecoderHTTP(dec transhttp.DecodeRequestFunc) transhttp.ServerOption

func RequestFromServerContextHTTP added in v0.2.6

func RequestFromServerContextHTTP(ctx context.Context) (*http.Request, bool)

func RequestQueryDecoderHTTP added in v0.2.6

func RequestQueryDecoderHTTP(dec transhttp.DecodeRequestFunc) transhttp.ServerOption

func RequestVarsDecoderHTTP added in v0.2.6

func RequestVarsDecoderHTTP(dec transhttp.DecodeRequestFunc) transhttp.ServerOption

func ResponseEncoderHTTP added in v0.2.6

func ResponseEncoderHTTP(en transhttp.EncodeResponseFunc) transhttp.ServerOption

func SetCookieHTTP added in v0.2.6

func SetCookieHTTP(ctx context.Context, cookie *http.Cookie)

func SetOperationHTTP added in v0.2.6

func SetOperationHTTP(ctx context.Context, op string)

func StreamInterceptorGRPC added in v0.2.6

func StreamInterceptorGRPC(in ...grpc.StreamServerInterceptor) transgrpc.ServerOption

func StreamMiddlewareGRPC added in v0.2.6

func StreamMiddlewareGRPC(m ...middleware.Middleware) transgrpc.ServerOption

func StrictSlashHTTP added in v0.2.6

func StrictSlashHTTP(strictSlash bool) transhttp.ServerOption

func TLSConfigGRPC added in v0.2.6

func TLSConfigGRPC(c *tls.Config) transgrpc.ServerOption

func TLSConfigHTTP added in v0.2.6

func TLSConfigHTTP(c *tls.Config) transhttp.ServerOption

func TimeoutGRPC added in v0.2.6

func TimeoutGRPC(timeout time.Duration) transgrpc.ServerOption

func TimeoutHTTP added in v0.2.6

func TimeoutHTTP(timeout time.Duration) transhttp.ServerOption

func UnaryInterceptorGRPC added in v0.2.6

func UnaryInterceptorGRPC(in ...grpc.UnaryServerInterceptor) transgrpc.ServerOption

func WithBlockHTTP added in v0.2.6

func WithBlockHTTP() transhttp.ClientOption

func WithContainer added in v0.2.6

func WithContainer(c interfaces.Container) options.Option

WithContainer sets the application component container.

func WithDiscoveryGRPC added in v0.2.6

func WithDiscoveryGRPC(d registry.Discovery) transgrpc.ClientOption

func WithDiscoveryHTTP added in v0.2.6

func WithDiscoveryHTTP(d registry.Discovery) transhttp.ClientOption

func WithEndpointGRPC added in v0.2.6

func WithEndpointGRPC(endpoint string) transgrpc.ClientOption

func WithEndpointHTTP added in v0.2.6

func WithEndpointHTTP(endpoint string) transhttp.ClientOption

func WithErrorDecoderHTTP added in v0.2.6

func WithErrorDecoderHTTP(errorDecoder transhttp.DecodeErrorFunc) transhttp.ClientOption

func WithHealthCheckGRPC added in v0.2.6

func WithHealthCheckGRPC(healthCheck bool) transgrpc.ClientOption

func WithLoggerGRPC added in v0.2.6

func WithLoggerGRPC(p0 log.Logger) transgrpc.ClientOption

func WithMiddlewareGRPC added in v0.2.6

func WithMiddlewareGRPC(m ...middleware.Middleware) transgrpc.ClientOption

func WithMiddlewareHTTP added in v0.2.6

func WithMiddlewareHTTP(m ...middleware.Middleware) transhttp.ClientOption

func WithNodeFilterGRPC added in v0.2.6

func WithNodeFilterGRPC(filters ...selector.NodeFilter) transgrpc.ClientOption

func WithNodeFilterHTTP added in v0.2.6

func WithNodeFilterHTTP(filters ...selector.NodeFilter) transhttp.ClientOption

func WithOptionsGRPC added in v0.2.6

func WithOptionsGRPC(opts ...grpc.DialOption) transgrpc.ClientOption

func WithPrintDiscoveryDebugLogGRPC added in v0.2.6

func WithPrintDiscoveryDebugLogGRPC(p bool) transgrpc.ClientOption

func WithRegistrar added in v0.2.6

func WithRegistrar(r ServerRegistrar) options.Option

WithRegistrar sets the ServerRegistrar for the service.

func WithRequestEncoderHTTP added in v0.2.6

func WithRequestEncoderHTTP(encoder transhttp.EncodeRequestFunc) transhttp.ClientOption

func WithResponseDecoderHTTP added in v0.2.6

func WithResponseDecoderHTTP(decoder transhttp.DecodeResponseFunc) transhttp.ClientOption

func WithStreamInterceptorGRPC added in v0.2.6

func WithStreamInterceptorGRPC(in ...grpc.StreamClientInterceptor) transgrpc.ClientOption

func WithSubsetGRPC added in v0.2.6

func WithSubsetGRPC(size int) transgrpc.ClientOption

func WithSubsetHTTP added in v0.2.6

func WithSubsetHTTP(size int) transhttp.ClientOption

func WithTLSConfigGRPC added in v0.2.6

func WithTLSConfigGRPC(c *tls.Config) transgrpc.ClientOption

func WithTLSConfigHTTP added in v0.2.6

func WithTLSConfigHTTP(c *tls.Config) transhttp.ClientOption

func WithTimeoutGRPC added in v0.2.6

func WithTimeoutGRPC(timeout time.Duration) transgrpc.ClientOption

func WithTimeoutHTTP added in v0.2.6

func WithTimeoutHTTP(d time.Duration) transhttp.ClientOption

func WithTransportHTTP added in v0.2.6

func WithTransportHTTP(trans http.RoundTripper) transhttp.ClientOption

func WithUnaryInterceptorGRPC added in v0.2.6

func WithUnaryInterceptorGRPC(in ...grpc.UnaryClientInterceptor) transgrpc.ClientOption

func WithUserAgentHTTP added in v0.2.6

func WithUserAgentHTTP(ua string) transhttp.ClientOption

Types

type CallOptionHTTP added in v0.2.6

type CallOptionHTTP = transhttp.CallOption

type ClientHTTP added in v0.2.6

type ClientHTTP = transhttp.Client

type ClientOptionGRPC added in v0.2.6

type ClientOptionGRPC = transgrpc.ClientOption

type ClientOptionHTTP added in v0.2.6

type ClientOptionHTTP = transhttp.ClientOption

type ContentTypeCallOptionHTTP added in v0.2.6

type ContentTypeCallOptionHTTP = transhttp.ContentTypeCallOption

type ContextHTTP added in v0.2.6

type ContextHTTP = transhttp.Context

type DecodeErrorFuncHTTP added in v0.2.6

type DecodeErrorFuncHTTP = transhttp.DecodeErrorFunc

type DecodeRequestFuncHTTP added in v0.2.6

type DecodeRequestFuncHTTP = transhttp.DecodeRequestFunc

type DecodeResponseFuncHTTP added in v0.2.6

type DecodeResponseFuncHTTP = transhttp.DecodeResponseFunc

type EmptyCallOptionHTTP added in v0.2.6

type EmptyCallOptionHTTP = transhttp.EmptyCallOption

type EncodeErrorFuncHTTP added in v0.2.6

type EncodeErrorFuncHTTP = transhttp.EncodeErrorFunc

type EncodeRequestFuncHTTP added in v0.2.6

type EncodeRequestFuncHTTP = transhttp.EncodeRequestFunc

type EncodeResponseFuncHTTP added in v0.2.6

type EncodeResponseFuncHTTP = transhttp.EncodeResponseFunc

type FilterFuncHTTP added in v0.2.6

type FilterFuncHTTP = transhttp.FilterFunc

type FlusherHTTP added in v0.2.6

type FlusherHTTP = transhttp.Flusher

type GRPCClient

type GRPCClient = grpc.ClientConn

GRPCClient define the gRPC client interface

type GRPCClientOption added in v0.0.4

type GRPCClientOption = transgrpc.ClientOption

GRPCClientOption define the gRPC client options

type GRPCRegisterFunc added in v0.2.6

type GRPCRegisterFunc func(ctx context.Context, srv *GRPCServer)

GRPCRegisterFunc is a function that implements GRPCRegistrar.

func (GRPCRegisterFunc) Register added in v0.2.6

func (f GRPCRegisterFunc) Register(ctx context.Context, srv any)

Register implements the ServerRegistrar interface for GRPCRegisterFunc.

func (GRPCRegisterFunc) RegisterGRPC added in v0.2.6

func (f GRPCRegisterFunc) RegisterGRPC(ctx context.Context, srv *GRPCServer)

RegisterGRPC implements the GRPCRegistrar interface for GRPCRegisterFunc.

type GRPCRegistrar added in v0.2.1

type GRPCRegistrar interface {
	RegisterGRPC(ctx context.Context, srv *GRPCServer)
}

GRPCRegistrar is a capability interface for services that can register gRPC endpoints.

type GRPCServer

type GRPCServer = transgrpc.Server

GRPCServer define the gRPC server interface

type GRPCServerOption added in v0.0.4

type GRPCServerOption = transgrpc.ServerOption

GRPCServerOption define the gRPC server options

type HTTPClient

type HTTPClient = transhttp.Client

HTTPClient define the HTTP client interface

type HTTPClientOption added in v0.0.4

type HTTPClientOption = transhttp.ClientOption

HTTPClientOption define the HTTP client options

type HTTPRegisterFunc added in v0.2.6

type HTTPRegisterFunc func(ctx context.Context, srv *HTTPServer)

HTTPRegisterFunc is a function that implements HTTPRegistrar.

func (HTTPRegisterFunc) Register added in v0.2.6

func (f HTTPRegisterFunc) Register(ctx context.Context, srv any)

Register implements the ServerRegistrar interface for HTTPRegisterFunc.

func (HTTPRegisterFunc) RegisterHTTP added in v0.2.6

func (f HTTPRegisterFunc) RegisterHTTP(ctx context.Context, srv *HTTPServer)

RegisterHTTP implements the HTTPRegistrar interface for HTTPRegisterFunc.

type HTTPRegistrar added in v0.2.1

type HTTPRegistrar interface {
	RegisterHTTP(ctx context.Context, srv *HTTPServer)
}

HTTPRegistrar is a capability interface for services that can register HTTP endpoints.

type HTTPServer

type HTTPServer = transhttp.Server

HTTPServer define the HTTP server interface

type HTTPServerOption added in v0.0.4

type HTTPServerOption = transhttp.ServerOption

HTTPServerOption define the HTTP server options

type HandlerFuncHTTP added in v0.2.6

type HandlerFuncHTTP = transhttp.HandlerFunc

type HeaderCallOptionHTTP added in v0.2.6

type HeaderCallOptionHTTP = transhttp.HeaderCallOption

type OperationCallOptionHTTP added in v0.2.6

type OperationCallOptionHTTP = transhttp.OperationCallOption

type Options added in v0.2.0

type Options struct {
	// Registrar is used to register server information with a service discovery registry.
	Registrar ServerRegistrar

	// Container provides access to various application components, including middleware.
	Container interfaces.Container
}

Options is a container for all service-level options. It is configured via the options pattern and is intended to be used by transport factories. These options are typically provided during application bootstrap.

func FromOptions added in v0.2.6

func FromOptions(opts []options.Option) *Options

FromOptions creates a new Options struct by applying a slice of functional options.

type PathTemplateCallOptionHTTP added in v0.2.6

type PathTemplateCallOptionHTTP = transhttp.PathTemplateCallOption

type ProtocolFactory added in v0.2.6

type ProtocolFactory interface {
	NewServer(cfg *transportv1.Server, opts ...options.Option) (interfaces.Server, error)
	NewClient(ctx context.Context, cfg *transportv1.Client, opts ...options.Option) (interfaces.Client, error)
}

ProtocolFactory defines the factory standard for creating a specific protocol service instance。

func GetProtocolFactory added in v0.2.6

func GetProtocolFactory(name string) (ProtocolFactory, bool)

GetProtocolFactory retrieves a registered protocol factory by name from the default registry. This function is the public API for retrieval.

type RedirectorHTTP added in v0.2.6

type RedirectorHTTP = transhttp.Redirector

type RequestHTTP added in v0.2.6

type RequestHTTP = transhttp.Request

type ResponseControllerHTTP added in v0.2.6

type ResponseControllerHTTP = transhttp.ResponseController

type ResponseWriterHTTP added in v0.2.6

type ResponseWriterHTTP = transhttp.ResponseWriter

type RouteInfoHTTP added in v0.2.6

type RouteInfoHTTP = transhttp.RouteInfo

type RouterHTTP added in v0.2.6

type RouterHTTP = transhttp.Router

type ServerGRPC added in v0.2.6

type ServerGRPC = transgrpc.Server

type ServerHTTP added in v0.2.6

type ServerHTTP = transhttp.Server

type ServerOptionGRPC added in v0.2.6

type ServerOptionGRPC = transgrpc.ServerOption

type ServerOptionHTTP added in v0.2.6

type ServerOptionHTTP = transhttp.ServerOption

type ServerRegisterFunc added in v0.2.6

type ServerRegisterFunc func(ctx context.Context, srv any)

ServerRegisterFunc is a function that implements ServerRegistrar.

func (ServerRegisterFunc) Register added in v0.2.6

func (f ServerRegisterFunc) Register(ctx context.Context, srv any)

Register implements the ServerRegistrar interface for ServerRegisterFunc.

type ServerRegistrar added in v0.2.1

type ServerRegistrar interface {
	Register(ctx context.Context, srv any)
}

ServerRegistrar defines the single, universal entry point for service registration. It is the responsibility of the transport-specific factories to pass the correct server type (e.g., *GRPCServer or *HTTPServer) to the Register method. The implementation of this interface, typically within the user's project, is expected to perform a type switch to handle the specific server type.

type TargetHTTP added in v0.2.6

type TargetHTTP = transhttp.Target

type TrailerGRPC added in v0.2.6

type TrailerGRPC = transgrpc.Trailer

type TransportGRPC added in v0.2.6

type TransportGRPC = transgrpc.Transport

type TransportHTTP added in v0.2.6

type TransportHTTP = transhttp.Transport

type TransporterHTTP added in v0.2.6

type TransporterHTTP = transhttp.Transporter

type WalkRouteFuncHTTP added in v0.2.6

type WalkRouteFuncHTTP = transhttp.WalkRouteFunc

Directories

Path Synopsis
Package selector contains generated code by adptool.
Package selector contains generated code by adptool.
Package tls implements the functions, types, and interfaces for the module.
Package tls implements the functions, types, and interfaces for the module.
transport

Jump to

Keyboard shortcuts

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