mirror of
https://github.com/aljazceru/blastr.git
synced 2025-12-17 05:54:26 +01:00
More documentation
This commit is contained in:
35
README.md
35
README.md
@@ -18,6 +18,9 @@ With `wrangler`, you can build, test, and deploy your Worker with the following
|
||||
# install wrangler if you do not have it yet
|
||||
$ npm install -g wrangler
|
||||
|
||||
# log into cloudflare if you havent before
|
||||
$ wrangler login
|
||||
|
||||
# compiles your project to WebAssembly and will warn of any issues
|
||||
$ npm run build
|
||||
|
||||
@@ -28,6 +31,36 @@ $ npm run dev
|
||||
$ npm run deploy
|
||||
```
|
||||
|
||||
### Setup
|
||||
|
||||
There's a few cloudflare components that Blastr uses behind the scenes, namely a KV store and multiple queues to distribute the load.
|
||||
|
||||
Right now some of these are hardcoded for us since they have to map from the `wrangler.toml` file to the rust codebase. Need a TODO for making this more dynamic.
|
||||
|
||||
#### KV store
|
||||
|
||||
This doesn't rebroadcast events that have already been broadcasted before. So we have a KV for that.
|
||||
|
||||
```
|
||||
wrangler kv:namespace create PUBLISHED_NOTES
|
||||
wrangler kv:namespace create PUBLISHED_NOTES --preview
|
||||
```
|
||||
|
||||
#### Queues
|
||||
|
||||
```
|
||||
wrangler queues create nostr-events-pub-1-b
|
||||
wrangler queues create nostr-events-pub-2-b
|
||||
wrangler queues create nostr-events-pub-3-b
|
||||
wrangler queues create nostr-events-pub-4-b
|
||||
wrangler queues create nostr-events-pub-5-b
|
||||
wrangler queues create nostr-events-pub-6-b
|
||||
wrangler queues create nostr-events-pub-7-b
|
||||
wrangler queues create nostr-events-pub-8-b
|
||||
wrangler queues create nostr-events-pub-9-b
|
||||
wrangler queues create nostr-events-pub-10-b
|
||||
```
|
||||
|
||||
Read the latest `worker` crate documentation here: https://docs.rs/worker
|
||||
|
||||
### CICD
|
||||
@@ -42,6 +75,8 @@ routes = [
|
||||
]
|
||||
```
|
||||
|
||||
and any other info in `wrangler.toml` that is custom to you, like the names / id's of queues or kv's.
|
||||
|
||||
### WebAssembly
|
||||
|
||||
`workers-rs` (the Rust SDK for Cloudflare Workers used in this template) is meant to be executed as compiled WebAssembly, and as such so **must** all the code you write and depend upon. All crates and modules used in Rust-based Workers projects have to compile to the `wasm32-unknown-unknown` triple.
|
||||
|
||||
@@ -2,12 +2,15 @@ name = "blastr"
|
||||
main = "build/worker/shim.mjs"
|
||||
compatibility_date = "2022-01-20"
|
||||
|
||||
# replace with your info
|
||||
# replace with your domain info - TODO this might not be required but we added it for ours.
|
||||
routes = [
|
||||
{ pattern = "nostr.mutinywallet.com/", zone_id = "2b9268714ce8d1c4431e8046d4ba55d3" },
|
||||
{ pattern = "nostr.mutinywallet.com/event", zone_id = "2b9268714ce8d1c4431e8046d4ba55d3" }
|
||||
]
|
||||
|
||||
# replace with your KV store info
|
||||
# create the queues with `wrangler kv:namespace create PUBLISHED_NOTES` and the same command with the `--preview` flag.
|
||||
# put your queue IDs below
|
||||
kv_namespaces = [
|
||||
{ binding = "PUBLISHED_NOTES", id = "afa24a392a5a41f6b1655507dfd9b97a", preview_id = "0b334aece8d74c3ab90e3e99db569ce8" }
|
||||
]
|
||||
@@ -15,6 +18,9 @@ kv_namespaces = [
|
||||
[vars]
|
||||
WORKERS_RS_VERSION = "0.0.13"
|
||||
|
||||
# Replace with all the queues you created, if you named them different.
|
||||
# create the queues with: `wrangler queues create {NAME}`
|
||||
# TODO make these more dynamic
|
||||
[[queues.producers]]
|
||||
queue = "nostr-events-pub-1-b"
|
||||
binding = "nostr-events-pub-1-b"
|
||||
|
||||
Reference in New Issue
Block a user