Documentation
¶
Overview ¶
Package server is a package that holds the http or grpc service.
Index ¶
- func NewCronServer(tasks []*gocron.Task, opts ...CronOption) app.IServer
- func NewGRPCServer(addr string, opts ...GrpcOption) app.IServer
- func NewHTTPServer(addr string, opts ...HTTPOption) app.IServer
- func NewRabbitmqConsumerServer(consumers []mq.Consumer, opts ...RabbitmqConsumerOption) app.IServer
- type CronOption
- type GrpcOption
- type HTTPOption
- func WithHTTPIdleTimeout(timeout time.Duration) HTTPOption
- func WithHTTPIsProd(isProd bool) HTTPOption
- func WithHTTPReadHeaderTimeout(timeout time.Duration) HTTPOption
- func WithHTTPReadTimeout(timeout time.Duration) HTTPOption
- func WithHTTPRegistry(iRegistry registry.Registry, instance *registry.ServiceInstance) HTTPOption
- func WithHTTPWriteTimeout(timeout time.Duration) HTTPOption
- type RabbitmqConsumerOption
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NewCronServer ¶ added in v1.3.8
func NewCronServer(tasks []*gocron.Task, opts ...CronOption) app.IServer
NewCronServer creates a new cron server
func NewGRPCServer ¶
func NewGRPCServer(addr string, opts ...GrpcOption) app.IServer
NewGRPCServer creates a new grpc server
func NewHTTPServer ¶
func NewHTTPServer(addr string, opts ...HTTPOption) app.IServer
NewHTTPServer 创建并返回一个 HTTP 服务实例,整合了路由引擎、超时配置和服务注册。 内部创建 Gin 路由引擎并与 http.Server 绑定,同时携带服务注册所需的实例信息。 注意:
- addr 格式应为 ":port"(如 ":8080"),由调用方保证格式正确,函数内部不做校验。
- 超时参数通过 HTTPOption 传入,零值表示不限制(由 http.Server 默认行为决定)。
- 若未提供 WithHTTPRegistry 选项,服务注册功能将被跳过,仅启动纯 HTTP 服务。
func NewRabbitmqConsumerServer ¶ added in v1.3.8
func NewRabbitmqConsumerServer(consumers []mq.Consumer, opts ...RabbitmqConsumerOption) app.IServer
NewRabbitmqConsumerServer 创建新的RabbitMQ消费者服务
Types ¶
type CronOption ¶ added in v1.4.40
type CronOption func(*cronOptions)
CronOption setting up cron
func WithCronRegistry ¶ added in v1.4.40
func WithCronRegistry(iRegistry registry.Registry, instance *registry.ServiceInstance) CronOption
WithCronRegistry registration services
type GrpcOption ¶
type GrpcOption func(*grpcOptions)
GrpcOption grpc settings
func WithGrpcRegistry ¶
func WithGrpcRegistry(iRegistry registry.Registry, instance *registry.ServiceInstance) GrpcOption
WithGrpcRegistry registration services
type HTTPOption ¶
type HTTPOption func(*httpOptions)
HTTPOption setting up http
func WithHTTPIdleTimeout ¶ added in v1.4.41
func WithHTTPIdleTimeout(timeout time.Duration) HTTPOption
WithHTTPIdleTimeout 设置 HTTP keep-alive 空闲超时
func WithHTTPIsProd ¶
func WithHTTPIsProd(isProd bool) HTTPOption
WithHTTPIsProd setting up production environment markers
func WithHTTPReadHeaderTimeout ¶ added in v1.4.41
func WithHTTPReadHeaderTimeout(timeout time.Duration) HTTPOption
WithHTTPReadHeaderTimeout 设置 HTTP 请求头读取超时
func WithHTTPReadTimeout ¶ added in v1.4.41
func WithHTTPReadTimeout(timeout time.Duration) HTTPOption
WithHTTPReadTimeout 设置 HTTP 读取超时
func WithHTTPRegistry ¶
func WithHTTPRegistry(iRegistry registry.Registry, instance *registry.ServiceInstance) HTTPOption
WithHTTPRegistry registration services
func WithHTTPWriteTimeout ¶ added in v1.4.41
func WithHTTPWriteTimeout(timeout time.Duration) HTTPOption
WithHTTPWriteTimeout 设置 HTTP 写入超时
type RabbitmqConsumerOption ¶ added in v1.4.40
type RabbitmqConsumerOption func(*rabbitmqConsumerOptions)
RabbitmqConsumerOption setting up rabbitmqConsumer
func WithRabbitmqConsumerRegistry ¶ added in v1.4.40
func WithRabbitmqConsumerRegistry(iRegistry registry.Registry, instance *registry.ServiceInstance) RabbitmqConsumerOption
WithRabbitmqConsumerRegistry registration services