Documentation
¶
Overview ¶
Package handlers binds the Connect-generated service interfaces to the prosa internal/server services (auth, sessions, devices).
Package handlers ships a plain HTTP SSE endpoint /sse/events that forwards Postgres NOTIFY events on channel "prosa.session.changed". This lives outside Connect because Connect's streaming surface isn't SSE-friendly enough to justify the wrapper; raw HTTP + EventSource on the browser side is simpler.
Index ¶
- type AnalyticsHandler
- type AppTokensHandler
- func (h *AppTokensHandler) Create(ctx context.Context, ...) (*connect.Response[prosav1.AppTokensServiceCreateResponse], error)
- func (h *AppTokensHandler) List(ctx context.Context, _ *connect.Request[prosav1.AppTokensServiceListRequest]) (*connect.Response[prosav1.AppTokensServiceListResponse], error)
- func (h *AppTokensHandler) Revoke(ctx context.Context, ...) (*connect.Response[prosav1.AppTokensServiceRevokeResponse], error)
- type AuthHandler
- func (h *AuthHandler) ApproveLogin(ctx context.Context, req *connect.Request[prosav1.ApproveLoginRequest]) (*connect.Response[prosav1.ApproveLoginResponse], error)
- func (h *AuthHandler) BeginLogin(ctx context.Context, req *connect.Request[prosav1.BeginLoginRequest]) (*connect.Response[prosav1.BeginLoginResponse], error)
- func (h *AuthHandler) ExchangeCode(ctx context.Context, req *connect.Request[prosav1.ExchangeCodeRequest]) (*connect.Response[prosav1.ExchangeCodeResponse], error)
- func (h *AuthHandler) GetLoginRequest(ctx context.Context, req *connect.Request[prosav1.GetLoginRequestRequest]) (*connect.Response[prosav1.GetLoginRequestResponse], error)
- func (h *AuthHandler) Whoami(ctx context.Context, _ *connect.Request[prosav1.WhoamiRequest]) (*connect.Response[prosav1.WhoamiResponse], error)
- type DevicesHandler
- func (h *DevicesHandler) List(ctx context.Context, _ *connect.Request[prosav1.DevicesServiceListRequest]) (*connect.Response[prosav1.DevicesServiceListResponse], error)
- func (h *DevicesHandler) Rename(ctx context.Context, req *connect.Request[prosav1.RenameRequest]) (*connect.Response[prosav1.RenameResponse], error)
- func (h *DevicesHandler) Revoke(ctx context.Context, req *connect.Request[prosav1.RevokeRequest]) (*connect.Response[prosav1.RevokeResponse], error)
- type PreferencesHandler
- func (h *PreferencesHandler) Delete(ctx context.Context, ...) (*connect.Response[prosav1.PreferencesServiceDeleteResponse], error)
- func (h *PreferencesHandler) Get(ctx context.Context, ...) (*connect.Response[prosav1.PreferencesServiceGetResponse], error)
- func (h *PreferencesHandler) Set(ctx context.Context, ...) (*connect.Response[prosav1.PreferencesServiceSetResponse], error)
- type SSEHandler
- type SessionsHandler
- func (h *SessionsHandler) Get(ctx context.Context, req *connect.Request[prosav1.GetRequest]) (*connect.Response[prosav1.GetResponse], error)
- func (h *SessionsHandler) GetRaw(ctx context.Context, req *connect.Request[prosav1.GetRawRequest]) (*connect.Response[prosav1.GetRawResponse], error)
- func (h *SessionsHandler) List(ctx context.Context, req *connect.Request[prosav1.ListRequest]) (*connect.Response[prosav1.ListResponse], error)
- func (h *SessionsHandler) ListChildren(ctx context.Context, req *connect.Request[prosav1.ListChildrenRequest]) (*connect.Response[prosav1.ListChildrenResponse], error)
- func (h *SessionsHandler) Manifest(ctx context.Context, req *connect.Request[prosav1.ManifestRequest]) (*connect.Response[prosav1.ManifestResponse], error)
- func (h *SessionsHandler) Push(ctx context.Context, req *connect.Request[prosav1.PushRequest]) (*connect.Response[prosav1.PushResponse], error)
- func (h *SessionsHandler) PushChunk(ctx context.Context, req *connect.Request[prosav1.PushChunkRequest]) (*connect.Response[prosav1.PushChunkResponse], error)
- func (h *SessionsHandler) Search(ctx context.Context, req *connect.Request[prosav1.SearchRequest]) (*connect.Response[prosav1.SearchResponse], error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AnalyticsHandler ¶
type AnalyticsHandler struct {
prosav1connect.UnimplementedAnalyticsServiceHandler
Pool *pgxpool.Pool
}
AnalyticsHandler implements AnalyticsService against Postgres. The CLI-facing reports (subagents included) mirror internal/store/analytics.go (which targets SQLite), rewritten with $N placeholders and tsvector FTS in place of FTS5. The remaining insights reports feed the panel only, with no SQLite mirror.
func NewAnalyticsHandler ¶
func NewAnalyticsHandler(pool *pgxpool.Pool) *AnalyticsHandler
func (*AnalyticsHandler) GetReport ¶
func (h *AnalyticsHandler) GetReport(ctx context.Context, req *connect.Request[prosav1.GetReportRequest]) (*connect.Response[prosav1.GetReportResponse], error)
GetReport dispatches by report name.
type AppTokensHandler ¶
type AppTokensHandler struct {
prosav1connect.UnimplementedAppTokensServiceHandler
Svc *auth.Service
}
AppTokensHandler implements owner-managed application tokens.
func NewAppTokensHandler ¶
func NewAppTokensHandler(svc *auth.Service) *AppTokensHandler
func (*AppTokensHandler) Create ¶
func (h *AppTokensHandler) Create(ctx context.Context, req *connect.Request[prosav1.AppTokensServiceCreateRequest]) (*connect.Response[prosav1.AppTokensServiceCreateResponse], error)
func (*AppTokensHandler) List ¶
func (h *AppTokensHandler) List(ctx context.Context, _ *connect.Request[prosav1.AppTokensServiceListRequest]) (*connect.Response[prosav1.AppTokensServiceListResponse], error)
func (*AppTokensHandler) Revoke ¶
func (h *AppTokensHandler) Revoke(ctx context.Context, req *connect.Request[prosav1.AppTokensServiceRevokeRequest]) (*connect.Response[prosav1.AppTokensServiceRevokeResponse], error)
type AuthHandler ¶
type AuthHandler struct {
prosav1connect.UnimplementedAuthServiceHandler
Svc *auth.Service
}
AuthHandler is the Connect implementation backed by *auth.Service.
func NewAuthHandler ¶
func NewAuthHandler(svc *auth.Service) *AuthHandler
func (*AuthHandler) ApproveLogin ¶
func (h *AuthHandler) ApproveLogin(ctx context.Context, req *connect.Request[prosav1.ApproveLoginRequest]) (*connect.Response[prosav1.ApproveLoginResponse], error)
func (*AuthHandler) BeginLogin ¶
func (h *AuthHandler) BeginLogin(ctx context.Context, req *connect.Request[prosav1.BeginLoginRequest]) (*connect.Response[prosav1.BeginLoginResponse], error)
func (*AuthHandler) ExchangeCode ¶
func (h *AuthHandler) ExchangeCode(ctx context.Context, req *connect.Request[prosav1.ExchangeCodeRequest]) (*connect.Response[prosav1.ExchangeCodeResponse], error)
func (*AuthHandler) GetLoginRequest ¶
func (h *AuthHandler) GetLoginRequest(ctx context.Context, req *connect.Request[prosav1.GetLoginRequestRequest]) (*connect.Response[prosav1.GetLoginRequestResponse], error)
func (*AuthHandler) Whoami ¶
func (h *AuthHandler) Whoami(ctx context.Context, _ *connect.Request[prosav1.WhoamiRequest]) (*connect.Response[prosav1.WhoamiResponse], error)
type DevicesHandler ¶
type DevicesHandler struct {
prosav1connect.UnimplementedDevicesServiceHandler
Pool *pgxpool.Pool
}
DevicesHandler implements the DevicesService Connect interface.
func NewDevicesHandler ¶
func NewDevicesHandler(pool *pgxpool.Pool) *DevicesHandler
func (*DevicesHandler) List ¶
func (h *DevicesHandler) List(ctx context.Context, _ *connect.Request[prosav1.DevicesServiceListRequest]) (*connect.Response[prosav1.DevicesServiceListResponse], error)
List returns every device row known to the server. Revoked devices are included with the revoked field set so the panel can show them dimmed; clients usually filter.
func (*DevicesHandler) Rename ¶
func (h *DevicesHandler) Rename(ctx context.Context, req *connect.Request[prosav1.RenameRequest]) (*connect.Response[prosav1.RenameResponse], error)
Rename sets devices.friendly_name. Accepts id="self" → caller's id. Device callers can only rename themselves; owner callers (panel) may rename any device.
func (*DevicesHandler) Revoke ¶
func (h *DevicesHandler) Revoke(ctx context.Context, req *connect.Request[prosav1.RevokeRequest]) (*connect.Response[prosav1.RevokeResponse], error)
Revoke marks all device_tokens for the target as revoked and stamps devices.revoked_at. Device callers can only revoke themselves; owner callers (panel) may revoke any device.
type PreferencesHandler ¶
type PreferencesHandler struct {
prosav1connect.UnimplementedPreferencesServiceHandler
Pool *pgxpool.Pool
}
PreferencesHandler implements the PreferencesService Connect interface. Only owner callers (the panel, authenticated via the admin token) may read or write; the owner_email in the request scopes the rows.
func NewPreferencesHandler ¶
func NewPreferencesHandler(pool *pgxpool.Pool) *PreferencesHandler
func (*PreferencesHandler) Delete ¶
func (h *PreferencesHandler) Delete(ctx context.Context, req *connect.Request[prosav1.PreferencesServiceDeleteRequest]) (*connect.Response[prosav1.PreferencesServiceDeleteResponse], error)
func (*PreferencesHandler) Get ¶
func (h *PreferencesHandler) Get(ctx context.Context, req *connect.Request[prosav1.PreferencesServiceGetRequest]) (*connect.Response[prosav1.PreferencesServiceGetResponse], error)
Get returns every stored preference for the owner as a key/value map.
func (*PreferencesHandler) Set ¶
func (h *PreferencesHandler) Set(ctx context.Context, req *connect.Request[prosav1.PreferencesServiceSetRequest]) (*connect.Response[prosav1.PreferencesServiceSetResponse], error)
Set upserts one preference for the owner. The panel validates the value against its own catalog before calling; the server stores it verbatim.
type SSEHandler ¶
SSEHandler streams session-changed events to authorized callers (panel). Callers prove authority with `Authorization: Admin <token>` — same scheme used by Connect's owner-mode interceptor.
func NewSSEHandler ¶
func NewSSEHandler(pool *pgxpool.Pool, adminToken string) *SSEHandler
func (*SSEHandler) ServeHTTP ¶
func (h *SSEHandler) ServeHTTP(w http.ResponseWriter, r *http.Request)
type SessionsHandler ¶
type SessionsHandler struct {
prosav1connect.UnimplementedSessionsServiceHandler
Pool *pgxpool.Pool
Obj *storage.ObjectStore
}
SessionsHandler implements the SessionsService Connect interface.
func NewSessionsHandler ¶
func NewSessionsHandler(pool *pgxpool.Pool, obj *storage.ObjectStore) *SessionsHandler
func (*SessionsHandler) Get ¶
func (h *SessionsHandler) Get(ctx context.Context, req *connect.Request[prosav1.GetRequest]) (*connect.Response[prosav1.GetResponse], error)
func (*SessionsHandler) GetRaw ¶
func (h *SessionsHandler) GetRaw(ctx context.Context, req *connect.Request[prosav1.GetRawRequest]) (*connect.Response[prosav1.GetRawResponse], error)
GetRaw streams a byte-range window of the session's raw transcript from S3.
func (*SessionsHandler) List ¶
func (h *SessionsHandler) List(ctx context.Context, req *connect.Request[prosav1.ListRequest]) (*connect.Response[prosav1.ListResponse], error)
func (*SessionsHandler) ListChildren ¶
func (h *SessionsHandler) ListChildren(ctx context.Context, req *connect.Request[prosav1.ListChildrenRequest]) (*connect.Response[prosav1.ListChildrenResponse], error)
ListChildren returns every session whose parent_session_id matches the request id, ordered started_at ASC so the panel can render them in spawn order.
func (*SessionsHandler) Manifest ¶
func (h *SessionsHandler) Manifest(ctx context.Context, req *connect.Request[prosav1.ManifestRequest]) (*connect.Response[prosav1.ManifestResponse], error)
func (*SessionsHandler) Push ¶
func (h *SessionsHandler) Push(ctx context.Context, req *connect.Request[prosav1.PushRequest]) (*connect.Response[prosav1.PushResponse], error)
func (*SessionsHandler) PushChunk ¶
func (h *SessionsHandler) PushChunk(ctx context.Context, req *connect.Request[prosav1.PushChunkRequest]) (*connect.Response[prosav1.PushChunkResponse], error)
func (*SessionsHandler) Search ¶
func (h *SessionsHandler) Search(ctx context.Context, req *connect.Request[prosav1.SearchRequest]) (*connect.Response[prosav1.SearchResponse], error)