matter

package
v1.4.16 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 14, 2026 License: BSD-3-Clause Imports: 18 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CollapseMainDatabaseName

func CollapseMainDatabaseName() string

func CollapseMongoURISecret

func CollapseMongoURISecret(uri string) (string, error)

func CollapseURIFor

func CollapseURIFor(purpose PurposeAffinity) (string, error)

func MaskMongoURI

func MaskMongoURI(uri string) string

Types

type Aggregation

type Aggregation struct {
	// contains filtered or unexported fields
}

func (Aggregation) AddFields

func (a Aggregation) AddFields(field bson.D) Aggregation

func (Aggregation) AppendFrom

func (a Aggregation) AppendFrom(agg Aggregation) Aggregation

func (Aggregation) Group

func (a Aggregation) Group(group bson.D) Aggregation

func (Aggregation) JsonString

func (a Aggregation) JsonString() string

mainly for debugging

func (Aggregation) Limit

func (a Aggregation) Limit(value int64) Aggregation

func (Aggregation) Log

func (a Aggregation) Log() slog.Attr

func (Aggregation) Lookup

func (a Aggregation) Lookup(lookup bson.D) Aggregation

func (Aggregation) Match

func (a Aggregation) Match(filter bson.D) Aggregation

func (Aggregation) Pipeline

func (a Aggregation) Pipeline() mongo.Pipeline

func (Aggregation) Project

func (a Aggregation) Project(fields bson.D) Aggregation

func (Aggregation) Search

func (a Aggregation) Search(fields bson.D) Aggregation

func (Aggregation) Sort

func (a Aggregation) Sort(fields bson.D) Aggregation

type Collapsible

type Collapsible interface {
	CollapseID() bson.ObjectID
	HasID() bool
	SelfScope() expression.Scope //return the scope of Self.  The scope should have enough information to UNIQUELY filter itself

	//An entity must be Collapse by an observer and Decohere the interaction's ripple in order to exists in a known state.
	//Failure to complete Collapse AND Decohere flow will put the state of the object in an UNKNOWN / INBETWEEN state.
	Collapse() Ripple             //return the ripple side effect after the collapse. Once Collapse is called the model is in an INBETWEEN state
	Decohere(ripple Ripple) error //After the collapse and interaction with environment, an entity decoheres (ripple contains materialization info)
}

type Dataverse added in v1.4.1

type Dataverse struct {
	EntityMeta meta.Metadata
}

func (*Dataverse) DataCollection added in v1.4.1

func (e *Dataverse) DataCollection() *mongo.Collection

type Detectable

type Detectable interface {
	GetID() bson.ObjectID
	HasID() bool
	LastObserved() time.Time
}

type Detector added in v1.4.1

type Detector[T Detectable] struct {
	Dataverse
	// contains filtered or unexported fields
}

func NewDetector added in v1.4.1

func NewDetector[T Detectable]() *Detector[T]

func (*Detector[T]) Filter added in v1.4.1

func (r *Detector[T]) Filter(filters ...expression.QueryFieldPredicate) *Detector[T]

func (*Detector[T]) FilterEither added in v1.4.1

func (r *Detector[T]) FilterEither(filters ...expression.QueryFieldPredicate) *Detector[T]

func (*Detector[T]) Limit added in v1.4.1

func (r *Detector[T]) Limit(limit int64) *Detector[T]

func (*Detector[T]) PipelineJSON added in v1.4.1

func (r *Detector[T]) PipelineJSON() string

func (Detector[T]) PullAll added in v1.4.1

func (r Detector[T]) PullAll(ctx context.Context) ([]T, error)

func (*Detector[T]) PullOne added in v1.4.1

func (r *Detector[T]) PullOne(ctx context.Context) (*T, error)

func (Detector[T]) RunPipeline added in v1.4.1

func (r Detector[T]) RunPipeline(ctx context.Context, postStages Aggregation) (*mongo.Cursor, error)

func (*Detector[T]) Sort added in v1.4.1

func (r *Detector[T]) Sort(field string, descending bool) *Detector[T]

func (*Detector[T]) SortLatest added in v1.4.1

func (r *Detector[T]) SortLatest() *Detector[T]

type EntityField

type EntityField struct {
	Name string
}

func (EntityField) Eq

func (EntityField) Gt

func (EntityField) Gte

func (EntityField) ID

func (q EntityField) ID() EntityIDField

func (EntityField) In

func (EntityField) Lt

func (EntityField) Lte

func (EntityField) Ne

func (EntityField) Nin

func (q EntityField) Nin(values ...any) expression.QueryFieldPredicate

func (EntityField) Str

func (EntityField) ToQueryPredicate

func (q EntityField) ToQueryPredicate(queryOp expression.QueryOp) expression.QueryFieldPredicate

type EntityIDField

type EntityIDField struct {
	EntityField
}

func (EntityIDField) In

--- Entity ID Field ---

func (EntityIDField) Nin

type EntityStringField

type EntityStringField struct {
	EntityField
}

func (EntityStringField) In

func (EntityStringField) Nin

type Member

type Member struct {
	Name           string    `bson:"name"`
	StateStr       string    `bson:"stateStr"`
	OptimeDate     time.Time `bson:"optimeDate"`
	SyncSourceHost string    `bson:"syncSourceHost"`
	Health         int       `bson:"health"` // 1 for up, 0 for down
}

Member defines the individual node status in the replica set

type MemberResponsibility

type MemberResponsibility struct {
	ReadDbs      []string
	ReadWriteDbs []string
	CreatorDbs   []string
	IsAdmin      bool
}

func (*MemberResponsibility) ToMongoRoles

func (r *MemberResponsibility) ToMongoRoles() []MongoRole

type MembersInfoResponse

type MembersInfoResponse struct {
	Users []MongoMember `bson:"users"`
}

type MongoDataverse

type MongoDataverse struct {
	// contains filtered or unexported fields
}

func SummonMongo

func SummonMongo(purpose PurposeAffinity) *MongoDataverse

func (*MongoDataverse) AdminDatabase

func (m *MongoDataverse) AdminDatabase() *mongo.Database

func (*MongoDataverse) BranchDatabase

func (m *MongoDataverse) BranchDatabase(branchName string) *mongo.Database

func (*MongoDataverse) Client

func (m *MongoDataverse) Client() *mongo.Client

func (*MongoDataverse) Close

func (m *MongoDataverse) Close()

func (*MongoDataverse) Collection

func (m *MongoDataverse) Collection(name string) *mongo.Collection

func (*MongoDataverse) Connect

func (m *MongoDataverse) Connect() (*mongo.Client, error)

func (*MongoDataverse) ListMembers

func (m *MongoDataverse) ListMembers() (*MembersInfoResponse, error)

func (*MongoDataverse) MainDatabase

func (m *MongoDataverse) MainDatabase() *mongo.Database

func (*MongoDataverse) ReelectPrimary

func (m *MongoDataverse) ReelectPrimary() error

func (*MongoDataverse) RemoveMember

func (m *MongoDataverse) RemoveMember(name string) error

func (*MongoDataverse) Status

func (m *MongoDataverse) Status() (*MongoStatus, error)

func (*MongoDataverse) UpdateMember

func (m *MongoDataverse) UpdateMember(name string, newPassword string, responsibility MemberResponsibility, upsert bool) error

type MongoMember

type MongoMember struct {
	User  string      `bson:"user"`
	Roles []MongoRole `bson:"roles"`
}

type MongoRole

type MongoRole struct {
	Role string `bson:"role"`
	DB   string `bson:"db"`
}

type MongoStatus

type MongoStatus struct {
	RSStatus     RSStatus
	ServerStatus ServerStatus
}

type Observer added in v1.4.1

type Observer[T Collapsible] struct {
	Dataverse
}

func NewObserver added in v1.4.1

func NewObserver[T Collapsible]() *Observer[T]

func (*Observer[T]) Record added in v1.4.1

func (r *Observer[T]) Record(ctx context.Context, object T) error

type PurposeAffinity

type PurposeAffinity int
const (
	PurposeAffinityUnknown PurposeAffinity = iota
	PurposeAffinityAdmin
	PurposeAffinityCreator
	PurposeAffinityObserver
	PurposeAffinityCount //Max Count/Value for PurposeAffinity
)

func (PurposeAffinity) String

func (p PurposeAffinity) String() string

type RSStatus

type RSStatus struct {
	Set     string   `bson:"set"`
	Members []Member `bson:"members"`
}

RSStatus defines the top-level response from replSetGetStatus

type Ripple

type Ripple struct {
	ID             bson.ObjectID
	State          RippleState
	Expr           bson.D
	Interstitial   map[string]any //state during the period of transition.
	InsertFeedback *mongo.InsertOneResult
	UpdateFeedback *mongo.UpdateResult
}

func (*Ripple) DoAddToSet added in v1.4.10

func (r *Ripple) DoAddToSet(key string, value any) *Ripple

func (*Ripple) DoIncr added in v1.4.5

func (r *Ripple) DoIncr(key string, value int) *Ripple

func (*Ripple) DoOperation added in v1.4.5

func (r *Ripple) DoOperation(operation string, key string, value any) *Ripple

func (*Ripple) DoSetOnInsert added in v1.4.5

func (r *Ripple) DoSetOnInsert(key string, value any) *Ripple

func (*Ripple) Get

func (r *Ripple) Get(key string) (any, bool)

func (Ripple) GetID

func (r Ripple) GetID() bson.ObjectID

func (*Ripple) GetOnInsertFor

func (r *Ripple) GetOnInsertFor(key string, defaultValue any) any

func (*Ripple) Set

func (r *Ripple) Set(key string, value any) *Ripple

func (Ripple) WasInserted

func (r Ripple) WasInserted() bool

type RippleState

type RippleState int32
const (
	RippleState_Unobservable RippleState = iota //failed state
	RippleState_FromUnknown                     //Forming into existence
	RippleState_FromKnown                       //Previously observed
)

type ServerStatus

type ServerStatus struct {
	Uptime      int64 `bson:"uptime"`
	Connections struct {
		Current   int `bson:"current"`
		Available int `bson:"available"`
	} `bson:"connections"`
	Opcounters struct {
		Insert  int64 `bson:"insert"`
		Query   int64 `bson:"query"`
		Update  int64 `bson:"update"`
		Delete  int64 `bson:"delete"`
		Command int64 `bson:"command"`
	} `bson:"opcounters"`
	Mem struct {
		Resident int64 `bson:"resident"` // in MB
		Virtual  int64 `bson:"virtual"`
	} `bson:"mem"`
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL