handler

package
v0.1.2 Latest Latest
Warning

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

Go to latest
Published: Jun 8, 2026 License: MIT Imports: 11 Imported by: 0

Documentation

Overview

Package handler glues slackproto + router + acpclient: it turns inbound Slack events into ACP prompts and streams the agent's session updates back into a Slack thread message.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	Router            *router.Router
	API               *slack.Client
	AllowedUserIDs    map[string]struct{}
	AllowedChannelIDs map[string]struct{}
	// PromptTimeout caps the wall-clock for a single prompt. Default 10m.
	PromptTimeout time.Duration
}

Config configures the handler.

type Handler

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

Handler implements slackproto.Handler.

func New

func New(cfg Config) *Handler

New constructs a handler.

func (*Handler) Handle

func (h *Handler) Handle(ctx context.Context, ev slackproto.Event)

Handle is called by slackproto.Client for each inbound event.

func (*Handler) SetAPI

func (h *Handler) SetAPI(api *slack.Client)

SetAPI installs the Slack API client (used for posting/updating messages). Called by main after the slackproto.Client has been constructed.

func (*Handler) WaitIdle

func (h *Handler) WaitIdle(ctx context.Context) error

WaitIdle blocks until the handler has no in-flight prompts or ctx is done. Used by tests to synchronise on the inflight-empty transition without wall-clock polling; also useful for graceful shutdown paths.

Implementation note: sync.Cond.Wait can't accept a context, so a helper goroutine bridges ctx → Broadcast. The helper exits as soon as WaitIdle returns (either because the map drained or ctx fired) — see the deferred close(stop) below — so there's no goroutine leak even on long-lived ctx.

Jump to

Keyboard shortcuts

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