Documentation
¶
Index ¶
Constants ¶
const (
// DefaultPort is default listening port.
DefaultPort = 8849
)
Variables ¶
var (
TCPNetWork = "tcp"
)
Functions ¶
Types ¶
type AbstractClient ¶
type AbstractClient interface {
// UnSubscribe helps you to unsubscribe the specific action of the table according to the req
UnSubscribe(req *SubscribeRequest) error
// IsClose checks whether the client is close
IsClosed() bool
// contains filtered or unexported methods
}
AbstractClient is the client interface for streaming subscription.
type DefaultMessageHandler ¶
type DefaultMessageHandler struct {
// contains filtered or unexported fields
}
DefaultMessageHandler is an implementation of MessageHandler, which is the default handler of IMessage.
func (*DefaultMessageHandler) DoEvent ¶
func (d *DefaultMessageHandler) DoEvent(msg IMessage)
DoEvent will be called when you subscribe with a goroutineClient or a goroutinePooledClient.
type GoroutineClient ¶
type GoroutineClient struct {
// contains filtered or unexported fields
}
GoroutineClient is an implementation of AbstractClient for streaming subscription.
func NewGoroutineClient ¶
func NewGoroutineClient(listeningHost string, listeningPort int) *GoroutineClient
NewGoroutineClient instantiates an instance of GoroutineClient, which is used to listen on the listening port to receive subscription info. When listeningHost is "", the default host is the local address. When listeningPort is 0, the default port is the 8849.
func (*GoroutineClient) Close ¶
func (t *GoroutineClient) Close()
Close closes the client and stop subscribing.
func (*GoroutineClient) IsClosed ¶
func (t *GoroutineClient) IsClosed() bool
IsClosed checks whether the client is closed.
func (*GoroutineClient) Subscribe ¶
func (t *GoroutineClient) Subscribe(req *SubscribeRequest) error
Subscribe helps you to subscribe the specific action of the table according to the req.
func (*GoroutineClient) UnSubscribe ¶
func (t *GoroutineClient) UnSubscribe(req *SubscribeRequest) error
UnSubscribe helps you to unsubscribe the specific action of the table according to the req.
type GoroutinePooledClient ¶
type GoroutinePooledClient struct {
// contains filtered or unexported fields
}
GoroutinePooledClient is an implementation of AbstractClient for streaming subscription.
func NewGoroutinePooledClient ¶
func NewGoroutinePooledClient(listeningHost string, listeningPort int) *GoroutinePooledClient
NewGoroutinePooledClient instantiates an instance of GoroutinePooledClient, which is used to listen on the listening port to receive subscription info. When listeningHost is "", the default host is the local address. When listeningPort is 0, the default port is the 8849.
func (*GoroutinePooledClient) Close ¶
func (t *GoroutinePooledClient) Close()
Close closes the client and stop subscribing.
func (*GoroutinePooledClient) IsClosed ¶
func (t *GoroutinePooledClient) IsClosed() bool
IsClosed checks whether the client is closed.
func (*GoroutinePooledClient) Subscribe ¶
func (t *GoroutinePooledClient) Subscribe(req *SubscribeRequest) error
Subscribe helps you to subscribe the specific action of the table according to the req.
func (*GoroutinePooledClient) UnSubscribe ¶
func (t *GoroutinePooledClient) UnSubscribe(req *SubscribeRequest) error
UnSubscribe helps you to unsubscribe the specific action of the table according to the req.
type IMessage ¶
type IMessage interface {
// GetTopic returns the topic in string format.
GetTopic() string
// GetOffset returns the offset of the subscription messages.
GetOffset() int64
// GetValue returns the value of the subscription messages based on the column index of the subscribed table.
GetValue(index int) model.DataForm
// GetValueByName returns the value of the subscription messages based on the column name of the subscribed table.
GetValueByName(name string) model.DataForm
}
IMessage is the interface of subscription messages.
type Message ¶
type Message struct {
// contains filtered or unexported fields
}
Message is the implementation of the IMessage.
type MessageHandler ¶
type MessageHandler interface {
// DoEvent will be called when you subscribe with a goroutineClient or a goroutinePooledClient
DoEvent(msg IMessage)
}
MessageHandler is an interface which will help you to handle message. You can implement the interface and use it when instantiate a SubscribeRequest or use DefaultMessageHandler by default.
type PollingClient ¶
type PollingClient struct {
// contains filtered or unexported fields
}
PollingClient is a client for streaming subscription, which allows you to get subscription from the topicPoller.
func NewPollingClient ¶
func NewPollingClient(listeningHost string, listeningPort int) *PollingClient
NewPollingClient instantiates a new polling client and listens on the listening port to get subscription.
func (*PollingClient) IsClosed ¶
func (t *PollingClient) IsClosed() bool
IsClosed checks whether the client is closed.
func (*PollingClient) Subscribe ¶
func (t *PollingClient) Subscribe(req *SubscribeRequest) (*TopicPoller, error)
Subscribe helps you to subscribe the specific action of the table according to the req.
func (*PollingClient) UnSubscribe ¶
func (t *PollingClient) UnSubscribe(req *SubscribeRequest) error
UnSubscribe helps you to unsubscribe the specific action of the table according to the req.
type SubscribeRequest ¶
type SubscribeRequest struct {
// Server address
Address string
// Name of the table to be subscribed
TableName string
// Name of the subscription task
ActionName string
// The amount of data processed at one time
BatchSize *int
// Offset of subscription
Offset int64
// When AllowExists=true, if the topic already exists before subscribing,
// the server will not throw an exception.
AllowExists bool
// timeout. unit: millisecond
Throttle *int
// whether to allow reconnection
Reconnect bool
// Specify parameter Filter with function setStreamTableFilterColumn.
// SetStreamTableFilterColumn specifies the filtering column of a stream table.
// Only the messages with filtering column values in filter are subscribed.
Filter *model.Vector
// handle subscription information
Handler MessageHandler
}
SubscribeRequest is used for subscribing.
func (*SubscribeRequest) SetBatchSize ¶
func (s *SubscribeRequest) SetBatchSize(bs int) *SubscribeRequest
SetBatchSize sets the batch size.
func (*SubscribeRequest) SetThrottle ¶
func (s *SubscribeRequest) SetThrottle(th int) *SubscribeRequest
SetThrottle sets the throttle.
type TopicPoller ¶
type TopicPoller struct {
// contains filtered or unexported fields
}
TopicPoller is used to take one or more subscription info for polling client.
func (*TopicPoller) Poll ¶
func (t *TopicPoller) Poll(timeout, size int) []IMessage
Poll retrieves and removes the head of this queue, waiting up to the specified wait time if necessary for an element to become available.
func (*TopicPoller) Take ¶
func (t *TopicPoller) Take() IMessage
Take retrieves and removes the head of this queue, waiting if necessary until an element becomes available.