hoytech / strfry

a nostr relay
GNU General Public License v3.0
489 stars 96 forks source link

Detect which strfry instance is accessing the policy plugin #44

Open alexgleason opened 1 year ago

alexgleason commented 1 year ago

Finally found a potential use-case for extending the policy plugin input message: figuring out which instance of strfry originated the message (when multiple strfry policies use the same plugin on a shared machine).

Inspired by this thread: https://gitlab.com/soapbox-pub/strfry-policies/-/issues/4#note_1426085367

cc @Giszmo

btw, not sure it's even a good idea yet or the best solution to that problem, just want to brainstorm. strfry doesn't even know its own relay URL anyway, right? just the port it's running on.

Giszmo commented 1 year ago

For me the question is how could one policy plugin instance serve multiple strfry processes? My policy might grow quite heavy and I want to stream from probably more than 30 relays. There should be a better approach than to load and run the plugin 30 times in parallel.

I'm now thinking I could probably stream the 30 relays into one strfry instance without complex polilcy and stream that into my other using the full policy. The first instance would just act as a buffer and delete all events older than an hour.

hoytech commented 1 year ago

@alexgleason - Yes you're right, a strfry instance doesn't know its own relay URL. I guess we could have a config value where you could label an instance and that would get passed in to the policy plugin. I'm not sure, I'd like to hear more about your use-case so we can decide if that's the best approach.

@Giszmo - I am planning on making a strfry router command that would let you stream to/from multiple different relays, and they could all share a single policy plugin instance. I don't have a timeframe in mind for this yet, sorry. So many other things I want to do first. Nice idea about the buffer instance - that would actually probably work pretty well!

Giszmo commented 1 year ago

I want to offer a relay for limited/mobile clients, to connect to one relay, only. My relay would track the relay lists of accounts and stream/aggregate relevant events from those.