Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type GuardOption ¶
type GuardOption func(*SessionGuard)
GuardOption configures a SessionGuard.
func WithPauseDuration ¶
func WithPauseDuration(d time.Duration) GuardOption
WithPauseDuration sets the pause duration after a session expiration.
type Handler ¶
type Handler func(ctx context.Context, msg types.WeixinMessage)
Handler is called for each incoming message.
type Monitor ¶
type Monitor struct {
// contains filtered or unexported fields
}
Monitor long-polls for new messages and dispatches them to a handler.
func NewMonitor ¶
func NewMonitor(c *client.Client, handler Handler, opts ...MonitorOption) *Monitor
NewMonitor creates a Monitor for the given client and handler.
type MonitorOption ¶
type MonitorOption func(*Monitor)
MonitorOption configures a Monitor.
func WithSessionGuard ¶
func WithSessionGuard(g *SessionGuard) MonitorOption
WithSessionGuard sets the session guard for pause-on-expiry behavior.
func WithSyncState ¶
func WithSyncState(s SyncState) MonitorOption
WithSyncState sets the sync state persistence backend.
type SessionGuard ¶
type SessionGuard struct {
// contains filtered or unexported fields
}
SessionGuard prevents API calls for a configurable duration after a session expiration is detected.
func NewSessionGuard ¶
func NewSessionGuard(opts ...GuardOption) *SessionGuard
NewSessionGuard creates a SessionGuard with a default pause duration of 1 hour.
func (*SessionGuard) Check ¶
func (g *SessionGuard) Check() error
Check returns an error if the guard is currently paused, or nil if API calls are allowed.
func (*SessionGuard) IsPaused ¶
func (g *SessionGuard) IsPaused() bool
IsPaused reports whether the guard is currently paused.
func (*SessionGuard) RemainingPause ¶
func (g *SessionGuard) RemainingPause() time.Duration
RemainingPause returns the remaining pause duration. Returns 0 if not paused.
func (*SessionGuard) Trigger ¶
func (g *SessionGuard) Trigger()
Trigger activates the pause, setting pauseUntil to now + pauseDuration.
type SyncState ¶
SyncState persists the long-poll sync buffer between restarts.
func NewFileSyncState ¶
NewFileSyncState returns a SyncState that persists to a JSON file.
func NewMemorySyncState ¶
func NewMemorySyncState() SyncState
NewMemorySyncState returns an in-memory SyncState with no persistence.