Some checks failed
Go / build-and-release (push) Has been cancelled
- Implement TraverseFollows using Cypher path queries on FOLLOWS relationships - Implement TraverseFollowers using reverse path traversal - Implement FindMentions using MENTIONS relationships from p-tags - Implement TraverseThread using REFERENCES relationships from e-tags with bidirectional traversal (inbound replies, outbound parents) - Add GraphAdapter to bridge Neo4j to graph.GraphDatabase interface - Add GraphResult type implementing graph.GraphResultI for Neo4j - Initialize graph executor for Neo4j backend in app/main.go The implementation uses existing Neo4j schema and relationships created by SaveEvent() - no schema changes required. The _graph extension now works transparently with either Badger or Neo4j backends. Bump version to v0.35.0 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
41 lines
1.4 KiB
Go
41 lines
1.4 KiB
Go
package neo4j
|
|
|
|
import (
|
|
"next.orly.dev/pkg/protocol/graph"
|
|
)
|
|
|
|
// GraphAdapter wraps a Neo4j database instance and implements graph.GraphDatabase interface.
|
|
// This allows the graph executor to call database traversal methods without
|
|
// the database package importing the graph package.
|
|
type GraphAdapter struct {
|
|
db *N
|
|
}
|
|
|
|
// NewGraphAdapter creates a new GraphAdapter wrapping the given Neo4j database.
|
|
func NewGraphAdapter(db *N) *GraphAdapter {
|
|
return &GraphAdapter{db: db}
|
|
}
|
|
|
|
// TraverseFollows implements graph.GraphDatabase.
|
|
func (a *GraphAdapter) TraverseFollows(seedPubkey []byte, maxDepth int) (graph.GraphResultI, error) {
|
|
return a.db.TraverseFollows(seedPubkey, maxDepth)
|
|
}
|
|
|
|
// TraverseFollowers implements graph.GraphDatabase.
|
|
func (a *GraphAdapter) TraverseFollowers(seedPubkey []byte, maxDepth int) (graph.GraphResultI, error) {
|
|
return a.db.TraverseFollowers(seedPubkey, maxDepth)
|
|
}
|
|
|
|
// FindMentions implements graph.GraphDatabase.
|
|
func (a *GraphAdapter) FindMentions(pubkey []byte, kinds []uint16) (graph.GraphResultI, error) {
|
|
return a.db.FindMentions(pubkey, kinds)
|
|
}
|
|
|
|
// TraverseThread implements graph.GraphDatabase.
|
|
func (a *GraphAdapter) TraverseThread(seedEventID []byte, maxDepth int, direction string) (graph.GraphResultI, error) {
|
|
return a.db.TraverseThread(seedEventID, maxDepth, direction)
|
|
}
|
|
|
|
// Verify GraphAdapter implements graph.GraphDatabase
|
|
var _ graph.GraphDatabase = (*GraphAdapter)(nil)
|