session

package
v0.3.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 23, 2026 License: MIT Imports: 3 Imported by: 0

Documentation

Overview

Package session provides session lifecycle guards for the WeChat iLink bot.

Index

Constants

View Source
const (
	// PauseDuration is how long to back off after receiving a session expired (-14) error.
	PauseDuration = 60 * time.Minute
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Guard

type Guard struct {
	// contains filtered or unexported fields
}

Guard tracks whether a bot session is currently paused due to expiry.

func NewGuard

func NewGuard() *Guard

NewGuard creates a new session guard.

func (*Guard) AssertActive

func (g *Guard) AssertActive() error

AssertActive returns an error if the session is currently paused.

func (*Guard) IsPaused

func (g *Guard) IsPaused() bool

IsPaused reports whether the session is still within its pause window. Expired pauses are auto-cleared.

func (*Guard) Pause

func (g *Guard) Pause()

Pause marks the session as paused for PauseDuration.

func (*Guard) Remaining

func (g *Guard) Remaining() time.Duration

Remaining returns the duration until the pause expires, or 0 if not paused. Callers should typically call IsPaused first to expire stale pauses.

func (*Guard) Reset

func (g *Guard) Reset()

Reset clears any active pause.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL