Documentation
¶
Overview ¶
Package server provides APIs for registering services and starting an RPC server.
Index ¶
- func SetProviderServices(sd *InternalService)
- type InternalService
- type MethodInfo
- type Server
- func (s *Server) GetRPCService(name string) common.RPCService
- func (s *Server) GetServiceInfo(name string) *common.ServiceInfo
- func (s *Server) GetServiceOptions(name string) *ServiceOptions
- func (s *Server) GetServiceOptionsByInterfaceName(interfaceName string) *ServiceOptions
- func (s *Server) Register(handler any, info *common.ServiceInfo, opts ...ServiceOption) error
- func (s *Server) RegisterService(handler any, opts ...ServiceOption) error
- func (s *Server) Serve() error
- type ServerOption
- func SetServerApplication(application *global.ApplicationConfig) ServerOption
- func SetServerMetrics(metrics *global.MetricsConfig) ServerOption
- func SetServerOtel(otel *global.OtelConfig) ServerOption
- func SetServerProtocols(pros map[string]*global.ProtocolConfig) ServerOption
- func SetServerProvider(provider *global.ProviderConfig) ServerOption
- func SetServerRegistries(regs map[string]*global.RegistryConfig) ServerOption
- func SetServerShutdown(shutdown *global.ShutdownConfig) ServerOption
- func SetServerTLS(tls *global.TLSConfig) ServerOption
- func WithServerAccesslog(accesslog string) ServerOption
- func WithServerAdaptiveService() ServerOption
- func WithServerAdaptiveServiceVerbose() ServerOption
- func WithServerAuth(auth string) ServerOption
- func WithServerCluster(cluster string) ServerOption
- func WithServerClusterAdaptiveService() ServerOption
- func WithServerClusterAvailable() ServerOption
- func WithServerClusterBroadcast() ServerOption
- func WithServerClusterFailBack() ServerOption
- func WithServerClusterFailFast() ServerOption
- func WithServerClusterFailOver() ServerOption
- func WithServerClusterFailSafe() ServerOption
- func WithServerClusterForking() ServerOption
- func WithServerClusterZoneAware() ServerOption
- func WithServerExecuteLimit(exeLimit string) ServerOption
- func WithServerExecuteLimitRejectedHandler(exeRejHandler string) ServerOption
- func WithServerFilter(filter string) ServerOption
- func WithServerFilterConf(conf any) ServerOption
- func WithServerGroup(group string) ServerOption
- func WithServerJSON() ServerOption
- func WithServerLoadBalance(lb string) ServerOption
- func WithServerLoadBalanceConsistentHashing() ServerOption
- func WithServerLoadBalanceLeastActive() ServerOption
- func WithServerLoadBalanceP2C() ServerOption
- func WithServerLoadBalanceRandom() ServerOption
- func WithServerLoadBalanceRoundRobin() ServerOption
- func WithServerNotRegister() ServerOption
- func WithServerParam(k, v string) ServerOption
- func WithServerParamSign(paramSign string) ServerOption
- func WithServerProtocol(opts ...protocol.ServerOption) ServerOption
- func WithServerProtocolIDs(protocolIDs []string) ServerOption
- func WithServerRegistry(opts ...registry.Option) ServerOption
- func WithServerRegistryIDs(registryIDs []string) ServerOption
- func WithServerRetries(retries int) ServerOption
- func WithServerSerialization(ser string) ServerOption
- func WithServerTLSOption(opts ...tls.Option) ServerOption
- func WithServerTag(tag string) ServerOption
- func WithServerToken(token string) ServerOption
- func WithServerTpsLimitRate(rate int) ServerOption
- func WithServerTpsLimitRejectedHandler(rejHandler string) ServerOption
- func WithServerTpsLimitStrategy(strategy string) ServerOption
- func WithServerTpsLimiter(limiter string) ServerOption
- func WithServerVersion(version string) ServerOption
- func WithServerWarmUp(warmUp time.Duration) ServerOption
- func WithServerWarmup(warmupDuration time.Duration) ServerOption
- type ServerOptions
- type ServiceDefinition
- type ServiceInfo
- type ServiceOption
- func SetApplication(application *global.ApplicationConfig) ServiceOption
- func SetProtocols(pros map[string]*global.ProtocolConfig) ServiceOption
- func SetProvider(provider *global.ProviderConfig) ServiceOption
- func SetRegistries(regs map[string]*global.RegistryConfig) ServiceOption
- func SetService(service *global.ServiceConfig) ServiceOption
- func WithAccesslog(accesslog string) ServiceOption
- func WithAuth(auth string) ServiceOption
- func WithCluster(cluster string) ServiceOption
- func WithClusterAdaptiveService() ServiceOption
- func WithClusterAvailable() ServiceOption
- func WithClusterBroadcast() ServiceOption
- func WithClusterFailBack() ServiceOption
- func WithClusterFailFast() ServiceOption
- func WithClusterFailOver() ServiceOption
- func WithClusterFailSafe() ServiceOption
- func WithClusterForking() ServiceOption
- func WithClusterZoneAware() ServiceOption
- func WithExecuteLimit(exeLimit string) ServiceOption
- func WithExecuteLimitRejectedHandler(exeRejHandler string) ServiceOption
- func WithFilter(filter string) ServiceOption
- func WithGroup(group string) ServiceOption
- func WithIDLMode(IDLMode string) ServiceOption
- func WithInterface(interfaceName string) ServiceOption
- func WithJSON() ServiceOption
- func WithLoadBalance(lb string) ServiceOption
- func WithLoadBalanceConsistentHashing() ServiceOption
- func WithLoadBalanceLeastActive() ServiceOption
- func WithLoadBalanceP2C() ServiceOption
- func WithLoadBalanceRandom() ServiceOption
- func WithLoadBalanceRoundRobin() ServiceOption
- func WithMethod(opts ...config.MethodOption) ServiceOption
- func WithNotRegister() ServiceOption
- func WithParam(k, v string) ServiceOption
- func WithParamSign(paramSign string) ServiceOption
- func WithProtocol(opts ...protocol.ServerOption) ServiceOption
- func WithProtocolIDs(protocolIDs []string) ServiceOption
- func WithRegistry(opts ...registry.Option) ServiceOption
- func WithRegistryIDs(registryIDs []string) ServiceOption
- func WithRetries(retries int) ServiceOption
- func WithSerialization(ser string) ServiceOption
- func WithTag(tag string) ServiceOption
- func WithToken(token string) ServiceOption
- func WithTpsLimitRate(rate int) ServiceOption
- func WithTpsLimitRejectedHandler(rejHandler string) ServiceOption
- func WithTpsLimitStrategy(strategy string) ServiceOption
- func WithTpsLimiter(limiter string) ServiceOption
- func WithVersion(version string) ServiceOption
- func WithWarmUp(warmUp time.Duration) ServiceOption
- func WithWarmup(warmupDuration time.Duration) ServiceOption
- type ServiceOptions
- func (svcOpts *ServiceOptions) Export() error
- func (svcOpts *ServiceOptions) GetExportedUrls() []*common.URL
- func (svcOpts *ServiceOptions) Implement(rpcService common.RPCService)
- func (svcOpts *ServiceOptions) InitExported()
- func (svcOpts *ServiceOptions) IsExport() bool
- func (svcOpts *ServiceOptions) Prefix() string
- func (svcOpts *ServiceOptions) Unexport()
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func SetProviderServices ¶ added in v3.3.1
func SetProviderServices(sd *InternalService)
Types ¶
type InternalService ¶
type InternalService struct {
// This is required
// internal service name
Name string
// This is required
// This options is service configuration
// Return serviceDefinition and bool, where bool indicates whether it is exported
Init func(options *ServiceOptions) (*ServiceDefinition, bool)
// This options is InternalService.svcOpts itself
BeforeExport func(options *ServiceOptions)
// This options is InternalService.svcOpts itself
AfterExport func(options *ServiceOptions, err error)
// Priority of service exposure
// Lower numbers have the higher priority
// The default priority is 0
// The metadata service is exposed at the end
// If you have no requirements for the order of service exposure, you can use the default priority or not set
Priority int
// contains filtered or unexported fields
}
InternalService for dubbo internal services
type MethodInfo ¶
type MethodInfo = common.MethodInfo
MethodInfo Deprecated: common.MethodInfo type alias, just for compatible with old generate pb.go file
type Server ¶
type Server struct {
// contains filtered or unexported fields
}
func NewServer ¶
func NewServer(opts ...ServerOption) (*Server, error)
func (*Server) GetRPCService ¶ added in v3.3.1
func (s *Server) GetRPCService(name string) common.RPCService
GetRPCService retrieves the RPCService implementation for a service by its name/ID Returns nil if the service is not found or has no RPCService
func (*Server) GetServiceInfo ¶ added in v3.3.1
func (s *Server) GetServiceInfo(name string) *common.ServiceInfo
GetServiceInfo retrieves the ServiceInfo for a service by its name/ID Returns nil if the service is not found or has no ServiceInfo
func (*Server) GetServiceOptions ¶ added in v3.3.1
func (s *Server) GetServiceOptions(name string) *ServiceOptions
GetServiceOptions retrieves the ServiceOptions for a service by its name/ID
func (*Server) GetServiceOptionsByInterfaceName ¶ added in v3.3.1
func (s *Server) GetServiceOptionsByInterfaceName(interfaceName string) *ServiceOptions
GetServiceOptionsByInterfaceName retrieves the ServiceOptions for a service by its interface name Returns nil if no service is found with the given interface name
func (*Server) Register ¶
func (s *Server) Register(handler any, info *common.ServiceInfo, opts ...ServiceOption) error
Register assemble invoker chains like ProviderConfig.Load, init a service per call
func (*Server) RegisterService ¶ added in v3.3.1
func (s *Server) RegisterService(handler any, opts ...ServiceOption) error
RegisterService is for new Triple non-idl mode implement.
type ServerOption ¶
type ServerOption func(*ServerOptions)
func SetServerApplication ¶
func SetServerApplication(application *global.ApplicationConfig) ServerOption
func SetServerMetrics ¶
func SetServerMetrics(metrics *global.MetricsConfig) ServerOption
func SetServerOtel ¶
func SetServerOtel(otel *global.OtelConfig) ServerOption
func SetServerProtocols ¶
func SetServerProtocols(pros map[string]*global.ProtocolConfig) ServerOption
func SetServerProvider ¶
func SetServerProvider(provider *global.ProviderConfig) ServerOption
func SetServerRegistries ¶
func SetServerRegistries(regs map[string]*global.RegistryConfig) ServerOption
func SetServerShutdown ¶
func SetServerShutdown(shutdown *global.ShutdownConfig) ServerOption
func SetServerTLS ¶ added in v3.3.1
func SetServerTLS(tls *global.TLSConfig) ServerOption
func WithServerAccesslog ¶
func WithServerAccesslog(accesslog string) ServerOption
func WithServerAdaptiveService ¶
func WithServerAdaptiveService() ServerOption
func WithServerAdaptiveServiceVerbose ¶
func WithServerAdaptiveServiceVerbose() ServerOption
func WithServerAuth ¶
func WithServerAuth(auth string) ServerOption
func WithServerCluster ¶
func WithServerCluster(cluster string) ServerOption
func WithServerClusterAdaptiveService ¶
func WithServerClusterAdaptiveService() ServerOption
func WithServerClusterAvailable ¶
func WithServerClusterAvailable() ServerOption
func WithServerClusterBroadcast ¶
func WithServerClusterBroadcast() ServerOption
func WithServerClusterFailBack ¶
func WithServerClusterFailBack() ServerOption
func WithServerClusterFailFast ¶
func WithServerClusterFailFast() ServerOption
func WithServerClusterFailOver ¶
func WithServerClusterFailOver() ServerOption
func WithServerClusterFailSafe ¶
func WithServerClusterFailSafe() ServerOption
func WithServerClusterForking ¶
func WithServerClusterForking() ServerOption
func WithServerClusterZoneAware ¶
func WithServerClusterZoneAware() ServerOption
func WithServerExecuteLimit ¶
func WithServerExecuteLimit(exeLimit string) ServerOption
func WithServerExecuteLimitRejectedHandler ¶
func WithServerExecuteLimitRejectedHandler(exeRejHandler string) ServerOption
func WithServerFilter ¶
func WithServerFilter(filter string) ServerOption
todo(DMwangnima): change Filter Option like Cluster and LoadBalance
func WithServerFilterConf ¶
func WithServerFilterConf(conf any) ServerOption
todo(DMwangnima): this configuration would be used by filter/hystrix think about a more ideal way to configure
func WithServerGroup ¶
func WithServerGroup(group string) ServerOption
func WithServerJSON ¶
func WithServerJSON() ServerOption
func WithServerLoadBalance ¶
func WithServerLoadBalance(lb string) ServerOption
func WithServerLoadBalanceConsistentHashing ¶
func WithServerLoadBalanceConsistentHashing() ServerOption
func WithServerLoadBalanceLeastActive ¶
func WithServerLoadBalanceLeastActive() ServerOption
func WithServerLoadBalanceP2C ¶
func WithServerLoadBalanceP2C() ServerOption
func WithServerLoadBalanceRandom ¶
func WithServerLoadBalanceRandom() ServerOption
func WithServerLoadBalanceRoundRobin ¶
func WithServerLoadBalanceRoundRobin() ServerOption
func WithServerNotRegister ¶
func WithServerNotRegister() ServerOption
func WithServerParam ¶
func WithServerParam(k, v string) ServerOption
func WithServerParamSign ¶
func WithServerParamSign(paramSign string) ServerOption
func WithServerProtocol ¶
func WithServerProtocol(opts ...protocol.ServerOption) ServerOption
func WithServerProtocolIDs ¶
func WithServerProtocolIDs(protocolIDs []string) ServerOption
todo(DMwangnima): think about a more ideal configuration style
func WithServerRegistry ¶
func WithServerRegistry(opts ...registry.Option) ServerOption
func WithServerRegistryIDs ¶
func WithServerRegistryIDs(registryIDs []string) ServerOption
todo(DMwangnima): think about a more ideal configuration style
func WithServerRetries ¶
func WithServerRetries(retries int) ServerOption
func WithServerSerialization ¶
func WithServerSerialization(ser string) ServerOption
func WithServerTLSOption ¶ added in v3.3.1
func WithServerTLSOption(opts ...tls.Option) ServerOption
WithServerTLSOption applies TLS options to the server configuration. It iterates over the provided tls. TLSOption and applies them to the ServerOptions.TLS field.
func WithServerTag ¶
func WithServerTag(tag string) ServerOption
func WithServerToken ¶
func WithServerToken(token string) ServerOption
WithToken should be used with WithFilter("token")
func WithServerTpsLimitRate ¶
func WithServerTpsLimitRate(rate int) ServerOption
func WithServerTpsLimitRejectedHandler ¶
func WithServerTpsLimitRejectedHandler(rejHandler string) ServerOption
func WithServerTpsLimitStrategy ¶
func WithServerTpsLimitStrategy(strategy string) ServerOption
func WithServerTpsLimiter ¶
func WithServerTpsLimiter(limiter string) ServerOption
func WithServerVersion ¶
func WithServerVersion(version string) ServerOption
func WithServerWarmUp ¶
func WithServerWarmUp(warmUp time.Duration) ServerOption
warmUp is in seconds
func WithServerWarmup ¶
func WithServerWarmup(warmupDuration time.Duration) ServerOption
type ServerOptions ¶
type ServerOptions struct {
Provider *global.ProviderConfig
Application *global.ApplicationConfig
Registries map[string]*global.RegistryConfig
Protocols map[string]*global.ProtocolConfig
Shutdown *global.ShutdownConfig
Metrics *global.MetricsConfig
Otel *global.OtelConfig
TLS *global.TLSConfig
}
type ServiceDefinition ¶
type ServiceDefinition struct {
Handler any
Info *common.ServiceInfo
Opts []ServiceOption
}
type ServiceInfo ¶
type ServiceInfo = common.ServiceInfo
ServiceInfo Deprecated: common.ServiceInfo type alias, just for compatible with old generate pb.go file
type ServiceOption ¶
type ServiceOption func(*ServiceOptions)
func SetApplication ¶
func SetApplication(application *global.ApplicationConfig) ServiceOption
func SetProtocols ¶
func SetProtocols(pros map[string]*global.ProtocolConfig) ServiceOption
func SetProvider ¶
func SetProvider(provider *global.ProviderConfig) ServiceOption
func SetRegistries ¶
func SetRegistries(regs map[string]*global.RegistryConfig) ServiceOption
func SetService ¶
func SetService(service *global.ServiceConfig) ServiceOption
func WithAccesslog ¶
func WithAccesslog(accesslog string) ServiceOption
func WithAuth ¶
func WithAuth(auth string) ServiceOption
func WithCluster ¶
func WithCluster(cluster string) ServiceOption
func WithClusterAdaptiveService ¶
func WithClusterAdaptiveService() ServiceOption
func WithClusterAvailable ¶
func WithClusterAvailable() ServiceOption
func WithClusterBroadcast ¶
func WithClusterBroadcast() ServiceOption
func WithClusterFailBack ¶
func WithClusterFailBack() ServiceOption
func WithClusterFailFast ¶
func WithClusterFailFast() ServiceOption
func WithClusterFailOver ¶
func WithClusterFailOver() ServiceOption
func WithClusterFailSafe ¶
func WithClusterFailSafe() ServiceOption
func WithClusterForking ¶
func WithClusterForking() ServiceOption
func WithClusterZoneAware ¶
func WithClusterZoneAware() ServiceOption
func WithExecuteLimit ¶
func WithExecuteLimit(exeLimit string) ServiceOption
func WithExecuteLimitRejectedHandler ¶
func WithExecuteLimitRejectedHandler(exeRejHandler string) ServiceOption
func WithFilter ¶
func WithFilter(filter string) ServiceOption
todo(DMwangnima): change Filter Option like Cluster and LoadBalance
func WithGroup ¶
func WithGroup(group string) ServiceOption
func WithIDLMode ¶ added in v3.3.1
func WithIDLMode(IDLMode string) ServiceOption
TODO: remove when config package is removed
func WithInterface ¶
func WithInterface(interfaceName string) ServiceOption
WithInterface sets the interface name for the service being exposed.
As a functional option, it is passed to a service registration function (e.g., RegisterGreetServiceHandler) to configure the service's properties.
The `interfaceName` acts as the unique identifier for this service in the registry. Clients (consumers) must use this exact name to discover and invoke the service.
Usage:
err := greet.RegisterGreetServiceHandler(
srv,
&GreetTripleServer{},
server.WithInterface("com.your.company.GreetService"),
)
func WithJSON ¶
func WithJSON() ServiceOption
func WithLoadBalance ¶
func WithLoadBalance(lb string) ServiceOption
func WithLoadBalanceConsistentHashing ¶
func WithLoadBalanceConsistentHashing() ServiceOption
func WithLoadBalanceLeastActive ¶
func WithLoadBalanceLeastActive() ServiceOption
func WithLoadBalanceP2C ¶
func WithLoadBalanceP2C() ServiceOption
func WithLoadBalanceRandom ¶
func WithLoadBalanceRandom() ServiceOption
func WithLoadBalanceRoundRobin ¶
func WithLoadBalanceRoundRobin() ServiceOption
func WithMethod ¶
func WithMethod(opts ...config.MethodOption) ServiceOption
func WithNotRegister ¶
func WithNotRegister() ServiceOption
func WithParam ¶
func WithParam(k, v string) ServiceOption
func WithParamSign ¶
func WithParamSign(paramSign string) ServiceOption
func WithProtocol ¶
func WithProtocol(opts ...protocol.ServerOption) ServiceOption
func WithProtocolIDs ¶
func WithProtocolIDs(protocolIDs []string) ServiceOption
todo(DMwangnima): think about a more ideal configuration style
func WithRegistry ¶
func WithRegistry(opts ...registry.Option) ServiceOption
func WithRegistryIDs ¶
func WithRegistryIDs(registryIDs []string) ServiceOption
todo(DMwangnima): think about a more ideal configuration style
func WithRetries ¶
func WithRetries(retries int) ServiceOption
func WithSerialization ¶
func WithSerialization(ser string) ServiceOption
func WithTag ¶
func WithTag(tag string) ServiceOption
func WithToken ¶
func WithToken(token string) ServiceOption
WithToken should be used with WithFilter("token")
func WithTpsLimitRate ¶
func WithTpsLimitRate(rate int) ServiceOption
func WithTpsLimitRejectedHandler ¶
func WithTpsLimitRejectedHandler(rejHandler string) ServiceOption
func WithTpsLimitStrategy ¶
func WithTpsLimitStrategy(strategy string) ServiceOption
func WithTpsLimiter ¶
func WithTpsLimiter(limiter string) ServiceOption
func WithVersion ¶
func WithVersion(version string) ServiceOption
func WithWarmup ¶
func WithWarmup(warmupDuration time.Duration) ServiceOption
type ServiceOptions ¶
type ServiceOptions struct {
Application *global.ApplicationConfig
Provider *global.ProviderConfig
Service *global.ServiceConfig
Registries map[string]*global.RegistryConfig
Protocols map[string]*global.ProtocolConfig
Id string
ProxyFactoryKey string
// for triple non-IDL mode
// consider put here or global.ServiceConfig
// string for url
// TODO: remove this when config package is remove
IDLMode string
// contains filtered or unexported fields
}
FIXME: ServiceOptions contains ServerOptions? Not ServerOptions contains ServiceOptions? we need to find a way to fix it.
func (*ServiceOptions) Export ¶ added in v3.3.1
func (svcOpts *ServiceOptions) Export() error
func (*ServiceOptions) GetExportedUrls ¶
func (svcOpts *ServiceOptions) GetExportedUrls() []*common.URL
GetExportedUrls will return the url in service config's exporter
func (*ServiceOptions) Implement ¶
func (svcOpts *ServiceOptions) Implement(rpcService common.RPCService)
Implement only store the @s and return
func (*ServiceOptions) InitExported ¶
func (svcOpts *ServiceOptions) InitExported()
InitExported will set exported as false atom bool
func (*ServiceOptions) IsExport ¶
func (svcOpts *ServiceOptions) IsExport() bool
IsExport will return whether the service config is exported or not
func (*ServiceOptions) Prefix ¶
func (svcOpts *ServiceOptions) Prefix() string
Prefix returns dubbo.service.${InterfaceName}.
func (*ServiceOptions) Unexport ¶
func (svcOpts *ServiceOptions) Unexport()
Unexport will call unexport of all exporters service config exported