Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(repository): add nip-50 search capability using meilisearch #122

Merged
merged 18 commits into from
Mar 4, 2025
Merged
Show file tree
Hide file tree
Changes from 11 commits
Commits
Show all changes
18 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
build
.vscode
.vscode
.idea/
6 changes: 4 additions & 2 deletions cmd/relay/relay.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import (
"github.com/dezh-tech/immortal/delivery/websocket"
"github.com/dezh-tech/immortal/infrastructure/database"
grpcclient "github.com/dezh-tech/immortal/infrastructure/grpc_client"
"github.com/dezh-tech/immortal/infrastructure/meilisearch"
"github.com/dezh-tech/immortal/infrastructure/metrics"
"github.com/dezh-tech/immortal/infrastructure/redis"
"github.com/dezh-tech/immortal/pkg/logger"
Expand All @@ -31,9 +32,10 @@ func New(cfg *config.Config) (*Relay, error) {
if err != nil {
return nil, err
}

m := metrics.New()

meili := meilisearch.New(cfg.MeiliConf)

r, err := redis.New(cfg.RedisConf)
if err != nil {
return nil, err
Expand Down Expand Up @@ -66,7 +68,7 @@ func New(cfg *config.Config) (*Relay, error) {
return nil, err
}

h := repository.New(cfg.Handler, db, c)
h := repository.New(cfg.Handler, db, meili, c)

ws, err := websocket.New(cfg.WebsocketServer, h, m, r, c)
if err != nil {
Expand Down
16 changes: 9 additions & 7 deletions config/config.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package config

import (
"github.com/dezh-tech/immortal/infrastructure/meilisearch"
"os"

"github.com/dezh-tech/immortal/delivery/grpc"
Expand All @@ -16,13 +17,14 @@ import (

// Config represents the configs used by relay and other concepts on system.
type Config struct {
Environment string `yaml:"environment"`
GRPCClient grpcclient.Config `yaml:"manager"`
WebsocketServer websocket.Config `yaml:"ws_server"`
Database database.Config `yaml:"database"`
RedisConf redis.Config `yaml:"redis"`
GRPCServer grpc.Config `yaml:"grpc_server"`
Logger logger.Config `yaml:"logger"`
Environment string `yaml:"environment"`
GRPCClient grpcclient.Config `yaml:"manager"`
WebsocketServer websocket.Config `yaml:"ws_server"`
Database database.Config `yaml:"database"`
RedisConf redis.Config `yaml:"redis"`
MeiliConf meilisearch.Config `yaml:"meili"`
GRPCServer grpc.Config `yaml:"grpc_server"`
Logger logger.Config `yaml:"logger"`
Handler repository.Config
}

Expand Down
14 changes: 14 additions & 0 deletions config/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,20 @@ redis:
# default is IMMO_WHITE_LIST.
white_list_filter_name: IMMO_WHITE_LIST

# meili contains MeiliSearch client specification
meili:

# host specifies the MeiliSearch server host
host: "localhost"

# port specifies the port on which the MeiliSearch server listens for requests
port: 7700

# timeout_in_ms specifies the maximum duration (in milliseconds) that is used for creating connections to the MeiliSearch server.
timeout_in_ms: 5000

# default_collection specifies the default collection name for documents
default_collection: "events"

# log contains configs for logs output in console and file.
logger:
Expand Down
2 changes: 1 addition & 1 deletion documents/NIPs.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
- [X] **NIP-40**: Expiration Timestamp
- [X] **NIP-42**: Authentication of Clients to Relays
- [ ] **NIP-45**: Event Counts
- [ ] **NIP-50**: Search Capability
- [X] **NIP-50**: Search Capability
- [X] **NIP-56**: Reporting
- [X] **NIP-59**: Gift Wrap
- [X] **NIP-62**: Right to Vanish
Expand Down
51 changes: 50 additions & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,13 @@ require (
github.com/gorilla/websocket v1.5.3
github.com/joho/godotenv v1.5.1
github.com/mailru/easyjson v0.9.0
github.com/meilisearch/meilisearch-go v0.31.0
github.com/prometheus/client_golang v1.20.5
github.com/redis/go-redis/v9 v9.7.0
github.com/rs/zerolog v1.33.0
github.com/stretchr/testify v1.10.0
github.com/testcontainers/testcontainers-go v0.35.0
github.com/testcontainers/testcontainers-go/modules/meilisearch v0.35.0
github.com/tidwall/gjson v1.18.0
go.mongodb.org/mongo-driver v1.17.2
google.golang.org/grpc v1.70.0
Expand All @@ -20,31 +23,77 @@ require (
)

require (
dario.cat/mergo v1.0.0 // indirect
github.com/Azure/go-ansiterm v0.0.0-20210617225240-d185dfc1b5a1 // indirect
github.com/Microsoft/go-winio v0.6.2 // indirect
github.com/andybalholm/brotli v1.1.1 // indirect
github.com/beorn7/perks v1.0.1 // indirect
github.com/btcsuite/btcd/chaincfg/chainhash v1.1.0 // indirect
github.com/cenkalti/backoff/v4 v4.3.0 // indirect
github.com/cespare/xxhash/v2 v2.3.0 // indirect
github.com/containerd/log v0.1.0 // indirect
github.com/containerd/platforms v0.2.1 // indirect
github.com/cpuguy83/dockercfg v0.3.2 // indirect
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/decred/dcrd/crypto/blake256 v1.1.0 // indirect
github.com/decred/dcrd/dcrec/secp256k1/v4 v4.3.0 // indirect
github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f // indirect
github.com/distribution/reference v0.6.0 // indirect
github.com/docker/docker v27.3.1+incompatible // indirect
github.com/docker/go-connections v0.5.0 // indirect
github.com/docker/go-units v0.5.0 // indirect
github.com/felixge/httpsnoop v1.0.4 // indirect
github.com/go-logr/logr v1.4.2 // indirect
github.com/go-logr/stdr v1.2.2 // indirect
github.com/go-ole/go-ole v1.2.6 // indirect
github.com/gogo/protobuf v1.3.2 // indirect
github.com/golang-jwt/jwt/v4 v4.5.1 // indirect
github.com/golang/snappy v0.0.4 // indirect
github.com/google/uuid v1.6.0 // indirect
github.com/josharian/intern v1.0.0 // indirect
github.com/klauspost/compress v1.17.11 // indirect
github.com/kr/text v0.2.0 // indirect
github.com/lufia/plan9stats v0.0.0-20211012122336-39d0f177ccd0 // indirect
github.com/magiconair/properties v1.8.7 // indirect
github.com/mattn/go-colorable v0.1.14 // indirect
github.com/mattn/go-isatty v0.0.20 // indirect
github.com/moby/docker-image-spec v1.3.1 // indirect
github.com/moby/patternmatcher v0.6.0 // indirect
github.com/moby/sys/sequential v0.5.0 // indirect
github.com/moby/sys/user v0.1.0 // indirect
github.com/moby/sys/userns v0.1.0 // indirect
github.com/moby/term v0.5.0 // indirect
github.com/montanaflynn/stats v0.7.1 // indirect
github.com/morikuni/aec v1.0.0 // indirect
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect
github.com/opencontainers/go-digest v1.0.0 // indirect
github.com/opencontainers/image-spec v1.1.0 // indirect
github.com/pkg/errors v0.9.1 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
github.com/power-devops/perfstat v0.0.0-20210106213030-5aafc221ea8c // indirect
github.com/prometheus/client_model v0.6.1 // indirect
github.com/prometheus/common v0.62.0 // indirect
github.com/prometheus/procfs v0.15.1 // indirect
github.com/shirou/gopsutil/v3 v3.23.12 // indirect
github.com/shoenig/go-m1cpu v0.1.6 // indirect
github.com/sirupsen/logrus v1.9.3 // indirect
github.com/stretchr/objx v0.5.2 // indirect
github.com/tidwall/match v1.1.1 // indirect
github.com/tidwall/pretty v1.2.1 // indirect
github.com/tklauser/go-sysconf v0.3.12 // indirect
github.com/tklauser/numcpus v0.6.1 // indirect
github.com/xdg-go/pbkdf2 v1.0.0 // indirect
github.com/xdg-go/scram v1.1.2 // indirect
github.com/xdg-go/stringprep v1.0.4 // indirect
github.com/youmark/pkcs8 v0.0.0-20240726163527-a2c0da244d78 // indirect
github.com/yusufpapurcu/wmi v1.2.3 // indirect
go.opentelemetry.io/auto/sdk v1.1.0 // indirect
go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.49.0 // indirect
go.opentelemetry.io/otel v1.34.0 // indirect
go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.34.0 // indirect
go.opentelemetry.io/otel/metric v1.34.0 // indirect
go.opentelemetry.io/otel/sdk v1.34.0 // indirect
go.opentelemetry.io/otel/trace v1.34.0 // indirect
go.opentelemetry.io/proto/otlp v1.5.0 // indirect
golang.org/x/crypto v0.32.0 // indirect
golang.org/x/net v0.34.0 // indirect
golang.org/x/sync v0.10.0 // indirect
Expand Down
Loading