Documentation
¶
Index ¶
- func OptDBHost(driver db.Drive, host, username, password string, databases ...string) dbOpts
- func OptDiscoverByRedis(opts ...redisOpts) discoverOpts
- func OptDiscoverByUDP(port int) discoverOpts
- func OptDiscoverInfo(name, alias, source, rootpath string, address map[ProtocolType]string) discoverOpts
- func OptDiscoverInfoTimeout(timeo, interval time.Duration) discoverOpts
- func OptMqttAddr(s string) mqttBrokerOpts
- func OptMqttAuth(user, pwd string) mqttOpts
- func OptMqttAuthConfig(ac *auth.Ledger) mqttBrokerOpts
- func OptMqttAuthFromfile(f string) mqttBrokerOpts
- func OptMqttClientBufferSize(s int) mqttBrokerOpts
- func OptMqttClientID(s string) mqttOpts
- func OptMqttFailureCache(max int, expire time.Duration, expireFunc func(topic string, body []byte)) mqttOpts
- func OptMqttHost(s string, t *tls.Config) mqttOpts
- func OptMqttInsideClient(b bool) mqttBrokerOpts
- func OptMqttMaxMsgExpirySeconds(t time.Duration) mqttBrokerOpts
- func OptMqttMaxSessionExpirySeconds(t time.Duration) mqttBrokerOpts
- func OptMqttRecvFunc(f func(topic string, body []byte)) mqttOpts
- func OptMqttSendTimeout(d time.Duration) mqttOpts
- func OptMqttSubscribe(s map[string]byte) mqttOpts
- func OptMqttTlsAddr(s string, t *tls.Config) mqttBrokerOpts
- func OptMqttTlsFromFile(s, cert, key, ca string) mqttBrokerOpts
- func OptMqttWSAddr(s string) mqttBrokerOpts
- func OptMqttWebAddr(s string) mqttBrokerOpts
- func OptRedisAddr(s string) redisOpts
- func OptRedisAuth(user, pwd string) redisOpts
- func OptRedisDatabase(i int) redisOpts
- func OptRedisReadTimeout(d time.Duration) redisOpts
- func OptRedisWriteTimeout(d time.Duration) redisOpts
- func OptRmqAuth(addr, host, user, pwd string, t *tls.Config) rmqOpts
- func OptRmqConsumer(exchange, queueName string, queueDurable, queueAutoDelete bool, ...) rmqOpts
- func OptRmqProducer(exchange string) rmqOpts
- func OptTCPBindAddr(s string) tcpOpts
- func OptTCPClient(c tcpfactory.Client) tcpOpts
- func OptTCPHelloMessages(m []*tcpfactory.SendMessage) tcpOpts
- func OptTCPReadTimeout(t time.Duration) tcpOpts
- func OptWebBind(s, cert, key string) webOpts
- func OptWebEngineFunc(f func() *gin.Engine) webOpts
- func OptWebHosts(hosts ...string) webOpts
- func OptWebTimeout(read, write, idle time.Duration) webOpts
- type Opt
- type Opts
- func SetMode(m RunMode) Opts
- func WithBoltDB(name string) Opts
- func WithDBClient(opts ...dbOpts) Opts
- func WithDiscover(opts ...discoverOpts) Opts
- func WithEmptyServer() Opts
- func WithLogger(l logger.Logger) Opts
- func WithMQTTBroker(opts ...mqttBrokerOpts) Opts
- func WithMqttClient(opts ...mqttOpts) Opts
- func WithRMQConsumer(opts ...rmqOpts) Opts
- func WithRedisClient(opts ...redisOpts) Opts
- func WithRmqProducer(opts ...rmqOpts) Opts
- func WithTCPServer(opts ...tcpOpts) Opts
- func WithWebServer(opts ...webOpts) Opts
- type ProtocolType
- type RunMode
- type Service
- func (s *Service) AppendRootPath(ss, sep string) string
- func (s *Service) DBClient(dbidx int) (*sql.DB, error)
- func (s *Service) DBExec(sql string, args ...interface{}) (int64, int64, error)
- func (s *Service) DBExecBydb(dbidx int, sql string, args ...interface{}) (int64, int64, error)
- func (s *Service) DBExecPrepare(sql string, args ...interface{}) error
- func (s *Service) DBExecPrepareBydb(dbidx int, sql string, args ...interface{}) error
- func (s *Service) DBOrm(dbidx int) (*gorm.DB, error)
- func (s *Service) DBQuery(sql string, rowcount int, args ...interface{}) (*db.QueryData, error)
- func (s *Service) DBQueryBydb(dbidx int, sql string, rowcount int, args ...interface{}) (*db.QueryData, error)
- func (s *Service) DoRequest(req *http.Request, opts ...httpclient.ReqOpts) (int, []byte, map[string]string, error)
- func (s *Service) MqttBrokerSubscribe(topic string, subscriptionId int, handler mqtt.InlineSubFn) error
- func (s *Service) MqttBrokerWrite(topic string, body []byte, qos byte) error
- func (s *Service) MqttWrite(topic string, body []byte, qos byte) error
- func (s *Service) PickAll() map[string]string
- func (s *Service) PickService(name string, protocol ProtocolType) (string, error)
- func (s *Service) RMQWrite(topic string, body []byte, expire time.Duration)
- func (s *Service) RedisClientLoaded() error
- func (s *Service) RedisDelHashField(key, field string) error
- func (s *Service) RedisDelKey(key string) error
- func (s *Service) RedisExpireKey(key string, expire time.Duration) error
- func (s *Service) RedisRead(key string) (string, error)
- func (s *Service) RedisReadHashField(key, field string) (string, error)
- func (s *Service) RedisReadHashMap(key string) (map[string]string, error)
- func (s *Service) RedisReadKeys(key string) ([]string, error)
- func (s *Service) RedisWrite(key string, value any, expire time.Duration) error
- func (s *Service) RedisWriteHashField(key, field string, value any) error
- func (s *Service) RedisWriteHashMap(key string, value map[string]any) error
- func (s *Service) Run()
- func (s *Service) Start()
- func (s *Service) TcpWrite(target string, msgs ...*tcpfactory.SendMessage)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func OptDiscoverByRedis ¶
func OptDiscoverByRedis(opts ...redisOpts) discoverOpts
func OptDiscoverByUDP ¶
func OptDiscoverByUDP(port int) discoverOpts
func OptDiscoverInfo ¶
func OptDiscoverInfo(name, alias, source, rootpath string, address map[ProtocolType]string) discoverOpts
func OptDiscoverInfoTimeout ¶
OptDiscoverInfoTimeout sets the timeout of service info.
The timeout should between 1 minute and 3 seconds.
func OptMqttAddr ¶
func OptMqttAddr(s string) mqttBrokerOpts
func OptMqttAuth ¶
func OptMqttAuth(user, pwd string) mqttOpts
func OptMqttAuthConfig ¶
func OptMqttAuthFromfile ¶
func OptMqttAuthFromfile(f string) mqttBrokerOpts
func OptMqttClientBufferSize ¶
func OptMqttClientBufferSize(s int) mqttBrokerOpts
func OptMqttClientID ¶
func OptMqttClientID(s string) mqttOpts
func OptMqttFailureCache ¶
func OptMqttHost ¶
func OptMqttInsideClient ¶
func OptMqttInsideClient(b bool) mqttBrokerOpts
func OptMqttRecvFunc ¶
func OptMqttSendTimeout ¶
func OptMqttSubscribe ¶
func OptMqttTlsAddr ¶
func OptMqttTlsFromFile ¶
func OptMqttTlsFromFile(s, cert, key, ca string) mqttBrokerOpts
func OptMqttWSAddr ¶
func OptMqttWSAddr(s string) mqttBrokerOpts
func OptMqttWebAddr ¶
func OptMqttWebAddr(s string) mqttBrokerOpts
func OptRedisAddr ¶
func OptRedisAddr(s string) redisOpts
func OptRedisAuth ¶
func OptRedisAuth(user, pwd string) redisOpts
func OptRedisDatabase ¶
func OptRedisDatabase(i int) redisOpts
func OptRedisReadTimeout ¶
func OptRedisWriteTimeout ¶
func OptRmqAuth ¶
func OptRmqConsumer ¶
func OptRmqProducer ¶
func OptRmqProducer(exchange string) rmqOpts
func OptTCPBindAddr ¶
func OptTCPBindAddr(s string) tcpOpts
func OptTCPClient ¶
func OptTCPClient(c tcpfactory.Client) tcpOpts
func OptTCPHelloMessages ¶
func OptTCPHelloMessages(m []*tcpfactory.SendMessage) tcpOpts
func OptTCPReadTimeout ¶
func OptWebBind ¶
func OptWebBind(s, cert, key string) webOpts
func OptWebEngineFunc ¶
func OptWebHosts ¶
func OptWebHosts(hosts ...string) webOpts
func OptWebTimeout ¶
Types ¶
type Opts ¶
type Opts func(opt *Opt)
func WithBoltDB ¶
func WithDBClient ¶
func WithDBClient(opts ...dbOpts) Opts
func WithDiscover ¶
func WithDiscover(opts ...discoverOpts) Opts
func WithEmptyServer ¶
func WithEmptyServer() Opts
func WithLogger ¶
func WithMQTTBroker ¶
func WithMQTTBroker(opts ...mqttBrokerOpts) Opts
func WithMqttClient ¶
func WithMqttClient(opts ...mqttOpts) Opts
func WithRMQConsumer ¶
func WithRMQConsumer(opts ...rmqOpts) Opts
func WithRedisClient ¶
func WithRedisClient(opts ...redisOpts) Opts
func WithRmqProducer ¶
func WithRmqProducer(opts ...rmqOpts) Opts
func WithTCPServer ¶
func WithTCPServer(opts ...tcpOpts) Opts
func WithWebServer ¶
func WithWebServer(opts ...webOpts) Opts
type ProtocolType ¶
type ProtocolType byte
const ( ProtocolTCP ProtocolType = iota ProtocolHTTP ProtocolHTTPS ProtocolMQTT ProtocolMQTTTLS ProtocolMQTTWS )
type Service ¶
type Service struct {
// contains filtered or unexported fields
}
func (*Service) AppendRootPath ¶
func (*Service) DBClient ¶
DBClient returns a *sql.DB connection for the specified database index. It ensures the database index is within the valid range before retrieving the SQL database client.
func (*Service) DBExecBydb ¶
func (*Service) DBExecPrepare ¶
func (*Service) DBExecPrepareBydb ¶
func (*Service) DBQueryBydb ¶
func (*Service) MqttBrokerSubscribe ¶
func (*Service) MqttBrokerWrite ¶
func (*Service) PickService ¶
func (s *Service) PickService(name string, protocol ProtocolType) (string, error)
func (*Service) RedisClientLoaded ¶
func (*Service) RedisDelHashField ¶
func (*Service) RedisDelKey ¶
func (*Service) RedisExpireKey ¶
func (*Service) RedisReadHashField ¶
func (*Service) RedisReadHashMap ¶
func (*Service) RedisWrite ¶
func (*Service) RedisWriteHashField ¶
func (*Service) RedisWriteHashMap ¶
func (*Service) TcpWrite ¶
func (s *Service) TcpWrite(target string, msgs ...*tcpfactory.SendMessage)
Source Files
¶
Click to show internal directories.
Click to hide internal directories.