···33A small service that receives events from the AT firehose and produces them to Kafka. Supports standard JSON outputs as well as [Osprey](https://github.com/roostorg/osprey)
44formatted events.
5566+Additionally, at-kafka supports subscribing to [Tap](https://github.com/bluesky-social/indigo/tree/main/cmd/tap) if youare attempting to perform a network backfill.
77+68## Usage
79810### Docker Compose
···11131214```yaml
1315environment:
1414- ATKAFKA_RELAY_HOST: "wss://bsky.network"
1515- ATKAFKA_BOOTSTRAP_SERVERS: "kafka:29092"
1616- ATKAFKA_OUTPUT_TOPIC: "atproto-events"
1717- ATKAFKA_OSPREY_COMPATIBLE: "false"
1818-```
1616+ # For relay mode
1717+ ATKAFKA_RELAY_HOST: "wss://bsky.network" # ATProto relay to subscribe to for events
19182020-Then start:
1919+ # For tap mode
2020+ ATKAFKA_TAP_HOST: "ws://localhost:2480" # Tap websocket host to subscribe to for events
2121+ ATKAFKA_DISABLE_ACKS: false # Whether to disable sending of acks to Tap
21222222-```bash
2323-docker compose up -d # Start services
2424-```
2525-2626-### Docker Run
2323+ # Kafka configuration
2424+ ATKAFKA_BOOTSTRAP_SERVERS: "kafka:29092" # Kafka bootstrap servers, comma separated
2525+ ATKAFKA_OUTPUT_TOPIC: "atproto-events" # The output topic for events
2626+ ATKAFKA_OSPREY_COMPATIBLE: false # Whether to produce Osprey-compatible events
27272828-For standard mode:
2828+ # Match only Blacksky PDS users
2929+ ATKAFKA_MATCHED_SERVICES: "blacksky.app" # A comma-separated list of PDSes to emit events for
3030+ # OR ignore anyone on Bluesky PBC PDSes
3131+ ATKAFKA_IGNORED_SERVICES: "*.bsky.network" # OR a comma-separated list of PDSes to _not_ emit events for
29323030-```bash
3131-docker run -d \
3232- -e ATKAFKA_BOOTSTRAP_SERVERS=kafka:9092 \
3333- -e ATKAFKA_OUTPUT_TOPIC=atproto-events \
3434- -p 2112:2112 \
3535- ghcr.io/haileyok/at-kafka:latest
3333+ # Match only Teal.fm records
3434+ ATKAFKA_MATCHED_COLLECTIONS: "fm.teal.*" # A comma-separated list of collections to emit events for
3535+ # OR ignore all Bluesky records
3636+ ATKAFKA_IGNORED_COLLECTIONS: "app.bsky.*" # OR a comma-separated list of collections to ignore events for
3637```
37383838-For Osprey-compatible mode:
3939+Then start:
39404041```bash
4141-docker run -d \
4242- -e ATKAFKA_BOOTSTRAP_SERVERS=kafka:9092 \
4343- -e ATKAFKA_OUTPUT_TOPIC=atproto-events \
4444- -e ATKAFKA_OSPREY_COMPATIBLE=true \
4545- -p 2112:2112 \
4646- ghcr.io/haileyok/at-kafka:latest
4747-```
4242+# For normal mode
4343+docker compose up -d
48444949-## Configuration
4545+# For tap mode
4646+docker compose -f docker-compose.tap.yml up -d
50475151-| Flag | Environment Variable | Default | Description |
5252-|------|---------------------|---------|-------------|
5353-| `--relay-host` | `ATKAFKA_RELAY_HOST` | `wss://bsky.network` | AT Protocol relay host to connect to |
5454-| `--bootstrap-servers` | `ATKAFKA_BOOTSTRAP_SERVERS` | (required) | Comma-separated list of Kafka bootstrap servers |
5555-| `--output-topic` | `ATKAFKA_OUTPUT_TOPIC` | (required) | Kafka topic to publish events to |
5656-| `--osprey-compatible` | `ATKAFKA_OSPREY_COMPATIBLE` | `false` | Enable Osprey-compatible event format |
4848+```
57495850## Event Structure
5951···143135144136- `atkafka_handled_events` - Total events that are received on the firehose and handled
145137- `atkafka_produced_events` - Total messages that are output on the bus
138138+- `atkafka_plc_requests` - Total number of PLC requests that were made, if applicable, and whether they were cached
139139+- `atkafka_api_requests` - Total number of API requests that were made, if applicable, and whether they were cached
140140+- `atkafka_cache_size` - The size of the PLC and API caches
141141+- `atkafka_acks_sent` - Total acks that were sent to Tap, if applicable
+10-3
atkafka/atkafka.go
···28282929type Server struct {
3030 relayHost string
3131+ tapHost string
3232+ disableAcks bool
3133 bootstrapServers []string
3234 outputTopic string
3335 ospreyCompat bool
···4244 plcClient *PlcClient
4345 apiClient *ApiClient
4446 logger *slog.Logger
4747+ ws *websocket.Conn
4548}
46494750type ServerArgs struct {
4851 // network params
4949- RelayHost string
5050- PlcHost string
5151- ApiHost string
5252+ RelayHost string
5353+ TapHost string
5454+ DisableAcks bool
5555+ PlcHost string
5656+ ApiHost string
52575358 // for watched and ignoed services or collections, only one list may be supplied
5459 // for both services and collections, wildcards are acceptable. for example:
···113118114119 s := &Server{
115120 relayHost: args.RelayHost,
121121+ tapHost: args.TapHost,
122122+ disableAcks: args.DisableAcks,
116123 plcClient: plcClient,
117124 apiClient: apiClient,
118125 bootstrapServers: args.BootstrapServers,