Documentation
¶
Index ¶
- Constants
- Variables
- func InitAck()
- func Initialize(ctx context.Context, eg *errgroup.Group, fn func(name string), ...)
- func NewClient(conn IConn, option *ClientOption, event IEvent) error
- type AckBuffer
- type AckBufferContent
- type Channel
- type Client
- type ClientOption
- type CloseEvent
- type DestroyEvent
- type Event
- type EventOption
- type GRPCStreamAdapter
- type IChannel
- type IClient
- type IConn
- type IDGenerator
- type IEvent
- type IStorage
- type IUpdatesRepository
- type InitOption
- type MessageEvent
- type OpenEvent
- type SenderContent
- func (s *SenderContent) Build() *accountpb.UpdateResponse
- func (s *SenderContent) BuildWithState(pts, date int64) *accountpb.UpdateResponse
- func (s *SenderContent) IsBroadcast() bool
- func (s *SenderContent) IsEphemeral() bool
- func (s *SenderContent) PersistUserIDs() []int
- func (s *SenderContent) SetAck(value bool) *SenderContent
- func (s *SenderContent) SetBroadcast(value bool) *SenderContent
- func (s *SenderContent) SetExclude(cid ...int64) *SenderContent
- func (s *SenderContent) SetPersistUserIDs(uids ...int) *SenderContent
- func (s *SenderContent) SetReceive(cid ...int64) *SenderContent
- func (s *SenderContent) SetUpdateMessageDeleted(update *accountpb.Update_MessageDeleted) *SenderContent
- func (s *SenderContent) SetUpdateMessageReaction(update *accountpb.Update_MessageReaction) *SenderContent
- func (s *SenderContent) SetUpdateMessageRead(update *accountpb.Update_MessageRead) *SenderContent
- func (s *SenderContent) SetUpdateNewMessage(update *accountpb.Update_NewMessage) *SenderContent
- func (s *SenderContent) SetUpdateRunnerEnabled(update *accountpb.Update_RunnerEnabled) *SenderContent
- func (s *SenderContent) SetUpdateUserStatus(update *accountpb.Update_UserStatus) *SenderContent
- func (s *SenderContent) SetUpdateUserTyping(update *accountpb.Update_UserTyping) *SenderContent
- type SnowflakeGenerator
- type StoredUpdate
Constants ¶
View Source
const DefaultWriteBufferSize = 10
View Source
const UpdatesBatchSize = 50
Variables ¶
View Source
var Session *session
Functions ¶
func Initialize ¶
Types ¶
type AckBuffer ¶
type AckBuffer struct {
TimeWheel *timeutil.SimpleTimeWheel[*AckBufferContent]
}
type AckBufferContent ¶
type AckBufferContent struct {
Cid int64
Uid int64
Channel string
Response *accountpb.UpdateResponse
}
type Channel ¶
type Channel struct {
// contains filtered or unexported fields
}
func NewChannel ¶
func NewChannel(name string, outChan chan *SenderContent, updatesRepository IUpdatesRepository) *Channel
func (*Channel) Write ¶
func (c *Channel) Write(data *SenderContent)
type ClientOption ¶
type ClientOption struct {
Uid int
Channel IChannel
Storage IStorage
IDGenerator IDGenerator
Buffer int
}
type CloseEvent ¶
type DestroyEvent ¶
type DestroyEvent func(client IClient)
type EventOption ¶
type EventOption func(event *Event)
func WithCloseEvent ¶
func WithCloseEvent(e CloseEvent) EventOption
func WithDestroyEvent ¶
func WithDestroyEvent(e DestroyEvent) EventOption
func WithMessageEvent ¶
func WithMessageEvent(e MessageEvent) EventOption
func WithOpenEvent ¶
func WithOpenEvent(e OpenEvent) EventOption
type GRPCStreamAdapter ¶
type GRPCStreamAdapter struct {
// contains filtered or unexported fields
}
func NewGRPCStreamAdapter ¶
func NewGRPCStreamAdapter(stream accountpb.AccountService_GetUpdatesServer) (*GRPCStreamAdapter, error)
func (*GRPCStreamAdapter) Close ¶
func (g *GRPCStreamAdapter) Close() error
func (*GRPCStreamAdapter) Read ¶
func (g *GRPCStreamAdapter) Read() ([]byte, error)
func (*GRPCStreamAdapter) SetCloseHandler ¶
func (g *GRPCStreamAdapter) SetCloseHandler(fn func(code int, text string) error)
func (*GRPCStreamAdapter) Write ¶
func (g *GRPCStreamAdapter) Write(data []byte) error
type IDGenerator ¶
type IDGenerator interface {
ID() int64
}
type IEvent ¶
type IEvent interface {
Open(client IClient)
Message(client IClient, data []byte)
Close(client IClient, code int, text string)
Destroy(client IClient)
}
func NewEvent ¶
func NewEvent(opts ...EventOption) IEvent
type IUpdatesRepository ¶
type InitOption ¶
type InitOption func(*initOptions)
func WithUpdatesRepository ¶
func WithUpdatesRepository(store IUpdatesRepository) InitOption
type MessageEvent ¶
type SenderContent ¶
type SenderContent struct {
// contains filtered or unexported fields
}
func NewSenderContent ¶
func NewSenderContent() *SenderContent
func (*SenderContent) Build ¶
func (s *SenderContent) Build() *accountpb.UpdateResponse
func (*SenderContent) BuildWithState ¶
func (s *SenderContent) BuildWithState(pts, date int64) *accountpb.UpdateResponse
func (*SenderContent) IsBroadcast ¶
func (s *SenderContent) IsBroadcast() bool
func (*SenderContent) IsEphemeral ¶
func (s *SenderContent) IsEphemeral() bool
func (*SenderContent) PersistUserIDs ¶
func (s *SenderContent) PersistUserIDs() []int
func (*SenderContent) SetAck ¶
func (s *SenderContent) SetAck(value bool) *SenderContent
func (*SenderContent) SetBroadcast ¶
func (s *SenderContent) SetBroadcast(value bool) *SenderContent
func (*SenderContent) SetExclude ¶
func (s *SenderContent) SetExclude(cid ...int64) *SenderContent
func (*SenderContent) SetPersistUserIDs ¶
func (s *SenderContent) SetPersistUserIDs(uids ...int) *SenderContent
func (*SenderContent) SetReceive ¶
func (s *SenderContent) SetReceive(cid ...int64) *SenderContent
func (*SenderContent) SetUpdateMessageDeleted ¶
func (s *SenderContent) SetUpdateMessageDeleted(update *accountpb.Update_MessageDeleted) *SenderContent
func (*SenderContent) SetUpdateMessageReaction ¶
func (s *SenderContent) SetUpdateMessageReaction(update *accountpb.Update_MessageReaction) *SenderContent
func (*SenderContent) SetUpdateMessageRead ¶
func (s *SenderContent) SetUpdateMessageRead(update *accountpb.Update_MessageRead) *SenderContent
func (*SenderContent) SetUpdateNewMessage ¶
func (s *SenderContent) SetUpdateNewMessage(update *accountpb.Update_NewMessage) *SenderContent
func (*SenderContent) SetUpdateRunnerEnabled ¶
func (s *SenderContent) SetUpdateRunnerEnabled(update *accountpb.Update_RunnerEnabled) *SenderContent
func (*SenderContent) SetUpdateUserStatus ¶
func (s *SenderContent) SetUpdateUserStatus(update *accountpb.Update_UserStatus) *SenderContent
func (*SenderContent) SetUpdateUserTyping ¶
func (s *SenderContent) SetUpdateUserTyping(update *accountpb.Update_UserTyping) *SenderContent
type SnowflakeGenerator ¶
func (*SnowflakeGenerator) ID ¶
func (g *SnowflakeGenerator) ID() int64
Click to show internal directories.
Click to hide internal directories.