Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ( ErrInvalidTlsKeyPair = errors.New("invalid TLS key pair") ErrPortBindingFailed = errors.New("failed to bind to the specified port") ErrInvalidPrivateKey = errors.New("invalid private key") ErrInvalidCertificate = errors.New("invalid certificate") ErrIOFailure = errors.New("I/O failure") )
Functions ¶
Types ¶
type DefaultService ¶ added in v1.0.0
type DefaultService struct{}
func (*DefaultService) OnListenFailed ¶ added in v1.0.0
func (*DefaultService) OnListenFailed(err error) time.Duration
func (*DefaultService) OnStopped ¶ added in v1.0.0
func (*DefaultService) OnStopped()
func (*DefaultService) OnStopping ¶ added in v1.0.0
func (*DefaultService) OnStopping()
type IGRPCService ¶ added in v1.0.0
type ITCPService ¶ added in v1.0.0
type ITCPService interface {
GetAddress() string
OnNewConnection(context.Context, net.Conn) bool // DO NOT block, start a TCPConnectionTask or handle the connection in a new goroutine if needed, return false to close the connection immediately
OnListenFailed(error) time.Duration
OnStopping()
OnStopped()
}
type NetServiceConfig ¶ added in v1.0.0
type NetServiceConfig struct {
Address string `json:"address" yaml:"address"` // Listening address, e.g., ":8080"
TLS *TLSConfig `json:"tls" yaml:"tls"` // [Optional] TLS configuration, if provided, the service will use TLS for secure communication
}
func (*NetServiceConfig) ListenTCP ¶ added in v1.0.0
func (cfg *NetServiceConfig) ListenTCP() (IAdapter, error)
type ServiceTask ¶
type ServiceTask struct {
// contains filtered or unexported fields
}
func NewGRPCService ¶ added in v1.0.0
func NewGRPCService(impl IGRPCService) *ServiceTask
func NewServiceTask ¶ added in v1.0.0
func NewServiceTask(delegate IService) *ServiceTask
func NewTCPServiceTask ¶ added in v1.0.0
func NewTCPServiceTask(delegate ITCPService) *ServiceTask
func (*ServiceTask) Run ¶ added in v1.0.0
func (t *ServiceTask) Run(mgr *TaskManager) *ServiceTask
func (*ServiceTask) Stop ¶ added in v1.0.0
func (t *ServiceTask) Stop()
type ServiceTaskFunc ¶ added in v1.0.0
deprecated, use TaskManager instead
func HttpServer ¶
deprecated
func HttpsServer ¶ added in v0.0.4
func HttpsServer(name, addr, certFile, keyFile string, initRouter func(context.Context) http.Handler) ServiceTaskFunc
deprecated
type TLSConfig ¶ added in v1.0.0
type TLSConfig struct {
Cert string `json:"cert" yaml:"cert"` // [Optional] SSL Certificate content or file path
Key string `json:"key" yaml:"key"` // [Optional] SSL Key content or file path
CAs []string `json:"ca" yaml:"ca"` // [Optional] CA Certificates content or file path for verifying client certificates, only used when SSL is enabled
ClientAuthType string `json:"client_auth_type" yaml:"client_auth_type"` // [Optional] Client authentication type, can be "none", "optional", "required", "must"
}
type TaskManager ¶ added in v1.0.0
type TaskManager struct {
// contains filtered or unexported fields
}
func NewTaskManager ¶ added in v1.0.0
func NewTaskManager() *TaskManager
func (*TaskManager) Run ¶ added in v1.0.0
func (tm *TaskManager) Run(task *ServiceTask) *ServiceTask
func (*TaskManager) RunMultiple ¶ added in v1.0.0
func (tm *TaskManager) RunMultiple(tasks ...*ServiceTask)
func (*TaskManager) Stop ¶ added in v1.0.0
func (tm *TaskManager) Stop()
func (*TaskManager) Wait ¶ added in v1.0.0
func (tm *TaskManager) Wait()
Click to show internal directories.
Click to hide internal directories.