tangled
alpha
login
or
join now
trezy.codes
/
quickslice
forked from
slices.network/quickslice
0
fork
atom
Auto-indexing service and GraphQL API for AT Protocol Records
0
fork
atom
overview
issues
pulls
pipelines
update goose with automatic retry
chadtmiller.com
4 months ago
51a4dc48
dfaf8a31
+12
-10
4 changed files
expand all
collapse all
unified
split
example
docker-compose.yml
server
gleam.toml
manifest.toml
src
jetstream_consumer.gleam
+1
-1
example/docker-compose.yml
···
11
11
environment:
12
12
- HOST=0.0.0.0
13
13
- PORT=8000
14
14
-
restart: unless-stopped
14
14
+
restart: on-failure:5
+1
-1
server/gleam.toml
···
33
33
envoy = ">= 1.0.2 and < 2.0.0"
34
34
dotenv_gleam = ">= 2.0.1 and < 3.0.0"
35
35
thoas = ">= 1.0.0 and < 2.0.0"
36
36
-
goose = ">= 1.0.0 and < 2.0.0"
36
36
+
goose = ">= 1.1.0 and < 2.0.0"
37
37
38
38
[dev-dependencies]
39
39
gleeunit = ">= 1.0.0 and < 2.0.0"
+2
-2
server/manifest.toml
···
22
22
{ name = "gleam_yielder", version = "1.1.0", build_tools = ["gleam"], requirements = ["gleam_stdlib"], otp_app = "gleam_yielder", source = "hex", outer_checksum = "8E4E4ECFA7982859F430C57F549200C7749823C106759F4A19A78AEA6687717A" },
23
23
{ name = "gleeunit", version = "1.6.1", build_tools = ["gleam"], requirements = ["gleam_stdlib"], otp_app = "gleeunit", source = "hex", outer_checksum = "FDC68A8C492B1E9B429249062CD9BAC9B5538C6FBF584817205D0998C42E1DAC" },
24
24
{ name = "glisten", version = "8.0.1", build_tools = ["gleam"], requirements = ["gleam_erlang", "gleam_otp", "gleam_stdlib", "logging", "telemetry"], otp_app = "glisten", source = "hex", outer_checksum = "534BB27C71FB9E506345A767C0D76B17A9E9199934340C975DC003C710E3692D" },
25
25
-
{ name = "goose", version = "1.0.0", build_tools = ["gleam"], requirements = ["ezstd", "gleam_erlang", "gleam_http", "gleam_json", "gleam_stdlib", "gun"], otp_app = "goose", source = "hex", outer_checksum = "A983AB3E25C6E8F3CC8BBB63A649AFCAFF6A23AC232AF28612D9B31643F07053" },
25
25
+
{ name = "goose", version = "1.1.0", build_tools = ["gleam"], requirements = ["ezstd", "gleam_erlang", "gleam_http", "gleam_json", "gleam_stdlib", "gun"], otp_app = "goose", source = "hex", outer_checksum = "6FF742DC1CFAC669537C490732F1552C70191A373F34FFB59B042E810BBA14E9" },
26
26
{ name = "gramps", version = "6.0.0", build_tools = ["gleam"], requirements = ["gleam_crypto", "gleam_erlang", "gleam_http", "gleam_stdlib"], otp_app = "gramps", source = "hex", outer_checksum = "8B7195978FBFD30B43DF791A8A272041B81E45D245314D7A41FC57237AA882A0" },
27
27
{ name = "graphql", version = "1.0.0", build_tools = ["gleam"], requirements = ["gleam_stdlib"], source = "local", path = "../graphql" },
28
28
{ name = "gun", version = "2.2.0", build_tools = ["make", "rebar3"], requirements = ["cowlib"], otp_app = "gun", source = "hex", outer_checksum = "76022700C64287FEB4DF93A1795CFF6741B83FB37415C40C34C38D2A4645261A" },
···
55
55
gleam_stdlib = { version = ">= 0.60.0 and < 1.0.0" }
56
56
gleam_time = { version = ">= 1.4.0 and < 2.0.0" }
57
57
gleeunit = { version = ">= 1.0.0 and < 2.0.0" }
58
58
-
goose = { version = ">= 1.0.0 and < 2.0.0" }
58
58
+
goose = { version = ">= 1.1.0 and < 2.0.0" }
59
59
graphql = { path = "../graphql" }
60
60
jose = { version = ">= 1.11.10 and < 2.0.0" }
61
61
lexicon = { path = "../lexicon" }
+8
-6
server/src/jetstream_consumer.gleam
···
43
43
Error(_) -> "wss://jetstream2.us-east.bsky.network/subscribe"
44
44
}
45
45
46
46
-
// Create Jetstream config
46
46
+
// Create Jetstream config with automatic retry
47
47
let config =
48
48
goose.JetstreamConfig(
49
49
endpoint: jetstream_url,
···
51
51
wanted_dids: [],
52
52
cursor: option.None,
53
53
max_message_size_bytes: option.None,
54
54
-
compress: True,
54
54
+
compress: False,
55
55
require_hello: False,
56
56
+
max_backoff_seconds: 60,
57
57
+
log_connection_events: True,
58
58
+
log_retry_attempts: False,
56
59
)
57
60
58
61
io.println("")
59
59
-
io.println("🌐 Connecting to Jetstream...")
62
62
+
io.println("Connecting to Jetstream...")
60
63
io.println(" Endpoint: " <> config.endpoint)
61
64
io.println(" DID filter: All DIDs (no filter)")
62
65
io.println("")
63
66
64
64
-
// Start the Jetstream consumer in a separate process
65
65
-
// This will run independently and call our event handler callback
67
67
+
// Start the Jetstream consumer (automatically retries on failure)
66
68
process.spawn_unlinked(fn() {
67
69
goose.start_consumer(config, fn(event_json) {
68
70
handle_jetstream_event(db, event_json)
69
71
})
70
72
})
71
73
72
72
-
io.println("✅ Jetstream consumer started")
74
74
+
io.println("Jetstream consumer started")
73
75
io.println("")
74
76
75
77
Ok(Nil)