Documentation
¶
Index ¶
- Constants
- Variables
- func BatchCheckEventsExist(boltdb *bolt.DB, eventIDs []string) map[string]bool
- func BatchWriteEvents(boltdb *bolt.DB, events []EventBlob) error
- func ConnectNeo4j(ctx context.Context, uri, user, password string) (neo4j.Driver, error)
- func ExpandReplaceableEvents(e roots.ValidatedEvent, s *EventSubgraph)
- func ExpandTaggedEvents(e roots.ValidatedEvent, s *EventSubgraph)
- func ExpandTaggedUsers(e roots.ValidatedEvent, s *EventSubgraph)
- func IsValidTag(t roots.Tag) bool
- func MergeNodes(ctx context.Context, tx neo4j.ManagedTransaction, batch NodeBatch) (neo4j.ResultSummary, error)
- func MergeRels(ctx context.Context, tx neo4j.ManagedTransaction, batch RelBatch) (neo4j.ResultSummary, error)
- func MergeSubgraph(ctx context.Context, driver neo4j.Driver, subgraph *BatchSubgraph) ([]neo4j.ResultSummary, error)
- func SetNeo4jSchema(ctx context.Context, driver neo4j.Driver) error
- func SetupBoltDB(boltdb *bolt.DB) error
- func ToCypherLabel(label string) string
- func ToCypherLabels(labels []string) string
- func ToCypherProps(keys []string, prefix string) string
- type BatchSubgraph
- func (s *BatchSubgraph) AddNode(node *Node) error
- func (s *BatchSubgraph) AddRel(rel *Relationship) error
- func (s *BatchSubgraph) NodeBatches() ([]NodeBatch, error)
- func (s *BatchSubgraph) NodeCount() int
- func (s *BatchSubgraph) RelBatches() ([]RelBatch, error)
- func (s *BatchSubgraph) RelCount() int
- type EventBlob
- type EventSubgraph
- func (s *EventSubgraph) AddNode(node *Node)
- func (s *EventSubgraph) AddRel(rel *Relationship)
- func (s *EventSubgraph) FirstNodeByLabel(label string) *Node
- func (s *EventSubgraph) Nodes() []*Node
- func (s *EventSubgraph) NodesByLabel(label string) []*Node
- func (s *EventSubgraph) Rels() []*Relationship
- type ExcludedEvent
- type Expander
- type ExpanderPipeline
- type MatchKeysProvider
- type Node
- type NodeBatch
- type Properties
- type RelBatch
- type Relationship
- func NewForUserRel(start *Node, end *Node, props Properties) *Relationship
- func NewIsReplaceableRel(start *Node, end *Node, props Properties) *Relationship
- func NewReferencesEventRel(start *Node, end *Node, props Properties) *Relationship
- func NewReferencesReplacementKeyRel(start *Node, end *Node, props Properties) *Relationship
- func NewReferencesUserRel(start *Node, end *Node, props Properties) *Relationship
- func NewRelationship(rtype string, start *Node, end *Node, props Properties) *Relationship
- func NewRelationshipWithValidation(rtype string, startLabel string, endLabel string, start *Node, end *Node, ...) *Relationship
- func NewSignedRel(start *Node, end *Node, props Properties) *Relationship
- func NewTaggedRel(start *Node, end *Node, props Properties) *Relationship
- func NewWithDTagRel(start *Node, end *Node, props Properties) *Relationship
- type SerializedNode
- type SerializedRel
- type SimpleMatchKeys
- type StringSet
- type WriteOptions
- type WriteReport
- type WriteResult
Constants ¶
const BucketName string = "events"
Variables ¶
var ErrDuplicate = errors.New("event already exists")
Functions ¶
func BatchCheckEventsExist ¶
func ConnectNeo4j ¶
func ExpandReplaceableEvents ¶
func ExpandReplaceableEvents(e roots.ValidatedEvent, s *EventSubgraph)
func ExpandTaggedEvents ¶
func ExpandTaggedEvents(e roots.ValidatedEvent, s *EventSubgraph)
func ExpandTaggedUsers ¶
func ExpandTaggedUsers(e roots.ValidatedEvent, s *EventSubgraph)
func IsValidTag ¶
func MergeNodes ¶
func MergeNodes( ctx context.Context, tx neo4j.ManagedTransaction, batch NodeBatch, ) (neo4j.ResultSummary, error)
func MergeRels ¶
func MergeRels( ctx context.Context, tx neo4j.ManagedTransaction, batch RelBatch, ) (neo4j.ResultSummary, error)
func MergeSubgraph ¶
func MergeSubgraph( ctx context.Context, driver neo4j.Driver, subgraph *BatchSubgraph, ) ([]neo4j.ResultSummary, error)
func SetNeo4jSchema ¶
SetNeo4jSchema ensures that the necessary indexes and constraints exist in the database
func SetupBoltDB ¶
func ToCypherLabel ¶
ToCypherLabel converts a node label or relationship type into its Cypher format.
func ToCypherLabels ¶
ToCypherLabels converts a list of node labels into its Cypher format.
func ToCypherProps ¶
Types ¶
type BatchSubgraph ¶
type BatchSubgraph struct {
// contains filtered or unexported fields
}
func NewBatchSubgraph ¶
func NewBatchSubgraph(matchProvider MatchKeysProvider) *BatchSubgraph
func (*BatchSubgraph) AddNode ¶
func (s *BatchSubgraph) AddNode(node *Node) error
func (*BatchSubgraph) AddRel ¶
func (s *BatchSubgraph) AddRel(rel *Relationship) error
func (*BatchSubgraph) NodeBatches ¶
func (s *BatchSubgraph) NodeBatches() ([]NodeBatch, error)
func (*BatchSubgraph) NodeCount ¶
func (s *BatchSubgraph) NodeCount() int
func (*BatchSubgraph) RelBatches ¶
func (s *BatchSubgraph) RelBatches() ([]RelBatch, error)
func (*BatchSubgraph) RelCount ¶
func (s *BatchSubgraph) RelCount() int
type EventSubgraph ¶
type EventSubgraph struct {
// contains filtered or unexported fields
}
func EventToSubgraph ¶
func EventToSubgraph(e roots.ValidatedEvent, p ExpanderPipeline) *EventSubgraph
func NewEventSubgraph ¶
func NewEventSubgraph() *EventSubgraph
func (*EventSubgraph) AddNode ¶
func (s *EventSubgraph) AddNode(node *Node)
func (*EventSubgraph) AddRel ¶
func (s *EventSubgraph) AddRel(rel *Relationship)
func (*EventSubgraph) FirstNodeByLabel ¶
func (s *EventSubgraph) FirstNodeByLabel(label string) *Node
func (*EventSubgraph) Nodes ¶
func (s *EventSubgraph) Nodes() []*Node
func (*EventSubgraph) NodesByLabel ¶
func (s *EventSubgraph) NodesByLabel(label string) []*Node
func (*EventSubgraph) Rels ¶
func (s *EventSubgraph) Rels() []*Relationship
type ExcludedEvent ¶
type ExcludedEvent struct {
Event roots.ValidatedEvent
Reason error
}
type Expander ¶
type Expander func(e roots.ValidatedEvent, s *EventSubgraph)
func DefaultExpanders ¶
func DefaultExpanders() []Expander
type ExpanderPipeline ¶
type ExpanderPipeline []Expander
func NewExpanderPipeline ¶
func NewExpanderPipeline(expanders ...Expander) ExpanderPipeline
type MatchKeysProvider ¶
type MatchKeysProvider interface {
// GetLabels returns the array of node labels in the mapping.
GetLabels() []string
// GetKeys returns the node property keys used to match nodes with the
// given label and a boolean indicating the success of the lookup.
GetKeys(label string) ([]string, bool)
}
MatchKeysProvider defines methods for querying a mapping of node labels and the property keys used to match nodes with them.
type Node ¶
type Node struct {
// Set of labels on the node.
Labels *StringSet
// Mapping of properties on the node.
Props Properties
}
Node represents a Neo4j node entity, encapsulating its labels and properties.
func NewEventNode ¶
func NewNode ¶
func NewNode(label string, props Properties) *Node
NewNode creates a new node with the given label and properties.
func NewRelayNode ¶
func NewReplacementKeyNode ¶
func NewTagNode ¶
func NewUserNode ¶
func (*Node) MatchProps ¶
func (n *Node) MatchProps( matchProvider MatchKeysProvider) (string, Properties, error)
MatchProps returns the node label and the property values to match it in the database.
func (*Node) Serialize ¶
func (n *Node) Serialize() *SerializedNode
type Properties ¶
Properties represents a map of node or relationship props.
type Relationship ¶
type Relationship struct {
// The relationship type.
Type string
// The start node for the relationship.
Start *Node
// The end node for the relationship.
End *Node
// Mapping of properties on the relationship
Props Properties
}
Relationship represents a Neo4j relationship between two nodes, including its type and properties.
func NewForUserRel ¶
func NewForUserRel( start *Node, end *Node, props Properties) *Relationship
func NewIsReplaceableRel ¶
func NewIsReplaceableRel( start *Node, end *Node, props Properties) *Relationship
func NewReferencesEventRel ¶
func NewReferencesEventRel( start *Node, end *Node, props Properties) *Relationship
func NewReferencesReplacementKeyRel ¶
func NewReferencesReplacementKeyRel( start *Node, end *Node, props Properties) *Relationship
func NewReferencesUserRel ¶
func NewReferencesUserRel( start *Node, end *Node, props Properties) *Relationship
func NewRelationship ¶
func NewRelationship( rtype string, start *Node, end *Node, props Properties) *Relationship
NewRelationship creates a new relationship with the given type, start node, end node, and properties
func NewRelationshipWithValidation ¶
func NewRelationshipWithValidation( rtype string, startLabel string, endLabel string, start *Node, end *Node, props Properties) *Relationship
func NewSignedRel ¶
func NewSignedRel( start *Node, end *Node, props Properties) *Relationship
func NewTaggedRel ¶
func NewTaggedRel( start *Node, end *Node, props Properties) *Relationship
func NewWithDTagRel ¶
func NewWithDTagRel( start *Node, end *Node, props Properties) *Relationship
func (*Relationship) Serialize ¶
func (r *Relationship) Serialize() *SerializedRel
type SerializedNode ¶
type SerializedNode = Properties
type SerializedRel ¶
type SerializedRel = map[string]Properties
type SimpleMatchKeys ¶
SimpleMatchKeys is a simple implementation of the MatchKeysProvider interface.
func NewSimpleMatchKeys ¶
func NewSimpleMatchKeys() *SimpleMatchKeys
func (*SimpleMatchKeys) GetLabels ¶
func (p *SimpleMatchKeys) GetLabels() []string
type StringSet ¶
type StringSet struct {
// contains filtered or unexported fields
}
func NewStringSet ¶
func (*StringSet) AsSortedArray ¶
type WriteOptions ¶
type WriteOptions struct {
Expanders ExpanderPipeline
BoltReadBatchSize int
}
type WriteReport ¶
type WriteReport struct {
ExcludedEvents []ExcludedEvent
CreatedEventCount int
Neo4jResultSummaries []neo4j.ResultSummary
Duration time.Duration
Error error
}
func WriteEvents ¶
func WriteEvents( events []roots.ValidatedEvent, driver neo4j.Driver, boltdb *bolt.DB, opts *WriteOptions, ) WriteReport
type WriteResult ¶
type WriteResult struct {
ResultSummaries []neo4j.ResultSummary
Error error
}
Source Files
¶
Directories
¶
| Path | Synopsis |
|---|---|
|
cmd
|
|
|
gen-fixtures
command
gen-fixtures generates cryptographically valid Nostr test events and writes them to testdata/events.json.
|
gen-fixtures generates cryptographically valid Nostr test events and writes them to testdata/events.json. |