external_events
feishu.integrations.external_events
¶
Authenticated durable intake and dispatch for non-Feishu events.
The application owns the job store, worker lifecycle, source credentials and notification mapping store. A successful intake means the event was saved, not that a handler ran or a Feishu message was delivered.
ExternalEvent
dataclass
¶
Event accepted from an authenticated service; source cannot be client supplied.
源代码位于: feishu/integrations/external_events.py
ExternalEventIntegration
dataclass
¶
Mount durable external-event intake on create_gateway.
Set both handler and a unique worker_id to run a worker in the
gateway lifespan. Without them the host must run an EventJobRunner.
Injected stores, handler and client remain owned by the application.
源代码位于: feishu/integrations/external_events.py
NotificationEventHandler
¶
Deliver external events as cards to explicitly authorized destinations.
The data fields use the regular notification format; data.event_id
identifies the incident/card, while the outer event ID identifies a single
delivery. Incident keys are scoped to the authenticated service and target.
A send or update is marked as an external effect before calling Feishu. An
ambiguous failure freezes the job as UNKNOWN for operator reconciliation.
源代码位于: feishu/integrations/external_events.py
| Python | |
|---|---|
243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 | |
create_external_event_route
¶
create_external_event_route(config: GatewayConfig, store: EventJobStore, *, path: str = '/events/external', authorize: EventAuthorizer | None = None, max_body_bytes: int = 1024 * 1024) -> Route
Persist authenticated external events before returning 202.
Each service is a FIFO partition, so events from that service cannot be
handled out of receipt order or concurrently. Use a store dedicated to
external events: the default Feishu event runner expects a different
envelope. Use EventJobRunner(..., payload_decoder=ExternalEvent.from_payload)
and run/poll that runner as part of the host application’s lifecycle.
Event IDs are unique per service. A replay with different content is a conflict. Authorization is checked before acceptance if supplied; handlers performing sensitive actions should also enforce authorization at execution.