add labels to subscriptions for easier debugging.

This commit is contained in:
fiatjaf 2025-08-14 13:27:29 -03:00
parent 23e27da077
commit d3975679e4
4 changed files with 15 additions and 5 deletions

View File

@ -141,7 +141,9 @@ var count = &cli.Command{
}
for _, relayUrl := range relayUrls {
relay, _ := sys.Pool.EnsureRelay(relayUrl)
count, hllRegisters, err := relay.Count(ctx, filter, nostr.SubscriptionOptions{})
count, hllRegisters, err := relay.Count(ctx, filter, nostr.SubscriptionOptions{
Label: "nak-count",
})
fmt.Fprintf(os.Stderr, "%s%s: ", strings.Repeat(" ", biggerUrlSize-len(relayUrl)), relayUrl)
if err != nil {

View File

@ -106,7 +106,9 @@ var fetch = &cli.Command{
continue
}
for ie := range sys.Pool.FetchMany(ctx, relays, filter, nostr.SubscriptionOptions{}) {
for ie := range sys.Pool.FetchMany(ctx, relays, filter, nostr.SubscriptionOptions{
Label: "nak-fetch",
}) {
stdout(ie.Event)
}
}

8
mcp.go
View File

@ -165,7 +165,9 @@ var mcpServer = &cli.Command{
res := strings.Builder{}
res.WriteString("Search results: ")
l := 0
for result := range sys.Pool.FetchMany(ctx, []string{"relay.nostr.band", "nostr.wine"}, filter, nostr.SubscriptionOptions{}) {
for result := range sys.Pool.FetchMany(ctx, []string{"relay.nostr.band", "nostr.wine"}, filter, nostr.SubscriptionOptions{
Label: "nak-mcp-search",
}) {
l++
pm, _ := sdk.ParseMetadata(result.Event)
res.WriteString(fmt.Sprintf("\n\nResult %d\nUser name: \"%s\"\nPublic key: \"%s\"\nDescription: \"%s\"\n",
@ -219,7 +221,9 @@ var mcpServer = &cli.Command{
}
}
events := sys.Pool.FetchMany(ctx, []string{relay}, filter, nostr.SubscriptionOptions{})
events := sys.Pool.FetchMany(ctx, []string{relay}, filter, nostr.SubscriptionOptions{
Label: "nak-mcp-profile-events",
})
result := strings.Builder{}
for ie := range events {

4
req.go
View File

@ -154,7 +154,9 @@ example:
fn = sys.Pool.SubscribeMany
}
for ie := range fn(ctx, relayUrls, filter, nostr.SubscriptionOptions{}) {
for ie := range fn(ctx, relayUrls, filter, nostr.SubscriptionOptions{
Label: "nak-req",
}) {
stdout(ie.Event)
}
}