Skip to content

Commit

Permalink
Document what the service does in the README
Browse files Browse the repository at this point in the history
  • Loading branch information
boreq committed Nov 22, 2023
1 parent 664a715 commit 652ee06
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 3 deletions.
23 changes: 23 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,24 @@
# Nos Event Service

A service which crawls relays to replicate events relevant to Nos users which
then get passed to other services e.g. the notification service or the
moderation service.

## Design

The service connects to all known relays and replicates the following events:
- all events of kinds defined in [`globalEventTypesToDownload`][global-event-kinds-to-download-search]
- all events created by Nos users or users in their contacts lists

The relays are discovered by using the code located in
[`RelaysExtractor`][relays-extractor-search] to scan nostr events. There is also
a set of bootstrap relays returned by
[`BootstrapRelaySource`][bootstrap-relay-source-search].

The contacts are discovered by using the code located in
[`ContactsExtractor`][contacts-extractor-search] to scan nostr events.


## Building and running

Build the program like so:
Expand Down Expand Up @@ -149,3 +168,7 @@ used in the following cases:
[code-review-comments]: https://github.com/golang/go/wiki/CodeReviewComments
[uber-style-guide]: https://github.com/uber-go/guide/blob/master/style.md

[global-event-kinds-to-download-search]: https://github.com/search?q=repo%3Aplanetary-social%2Fnos-event-service+globalEventKindsToDownload&type=code
[relays-extractor-search]: https://github.com/search?q=repo%3Aplanetary-social%2Fnos-event-service+RelaysExtractor&type=code
[contacts-extractor-search]: https://github.com/search?q=repo%3Aplanetary-social%2Fnos-event-service+ContactsExtractor&type=code
[bootstrap-relay-source-search]: https://github.com/search?q=repo%3Aplanetary-social%2Fnos-event-service%20BootstrapRelaySource&type=code
4 changes: 2 additions & 2 deletions service/app/downloader.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ const (
)

var (
globalEventTypesToDownload = []domain.EventKind{
globalEventKindsToDownload = []domain.EventKind{
domain.EventKindMetadata,
domain.EventKindRecommendedRelay,
domain.EventKindContacts,
Expand Down Expand Up @@ -216,7 +216,7 @@ func NewRelayDownloader(
func (d *RelayDownloader) Run(ctx context.Context) {
go d.downloadMessages(ctx, domain.NewFilter(
nil,
globalEventTypesToDownload,
globalEventKindsToDownload,
nil,
d.downloadSince(),
))
Expand Down
2 changes: 1 addition & 1 deletion service/app/handler_save_received_event.go
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ func (h *SaveReceivedEventHandler) shouldBeDirectlyMonitored(ctx context.Context
}

func (h *SaveReceivedEventHandler) shouldBeGloballyDownloaded(kind domain.EventKind) bool {
for _, v := range globalEventTypesToDownload {
for _, v := range globalEventKindsToDownload {
if v == kind {
return true
}
Expand Down

0 comments on commit 652ee06

Please sign in to comment.