mongodb

package
v0.7.0 Latest Latest
Warning

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

Go to latest
Published: Aug 5, 2022 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewEvaluationRepository

func NewEvaluationRepository(ctx context.Context, db *mongo.Database) (repository.Evaluation, error)

NewEvaluationRepository returns a new evaluation repository that uses mongodb as underlying storage. It also creates all needed indexes, if they don't yet exist.

func NewFlagRepository

func NewFlagRepository(ctx context.Context, db *mongo.Database) (repository.Flag, error)

NewFlagRepository returns a new flag repository that uses mongodb as underlying storage. It also creates all needed indexes, if they don't yet exist.

func NewRuleRepository

func NewRuleRepository(flagRepo *FlagRepository, segmentRepo *SegmentRepository) repository.Rule

NewRuleRepository returns a new rule repository that uses mongodb as underlying storage.

func NewSegmentRepository

func NewSegmentRepository(ctx context.Context, db *mongo.Database) (repository.Segment, error)

NewSegmentRepository returns a new segment repository that uses mongodb as underlying storage. It also creates all needed indexes, if they don't yet exist.

func NewUserRepository

func NewUserRepository(ctx context.Context, db *mongo.Database) (repository.User, error)

NewUserRepository returns a new user repository that uses mongodb as underlying storage. It also creates all needed indexes, if they don't yet exist.

func NewVariantRepository

func NewVariantRepository(flagRepo *FlagRepository) repository.Variant

NewVariantRepository returns a new variant repository that uses mongodb as underlying storage.

Types

type EvaluationRepository

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

EvaluationRepository implements repository.Flag interface using mongodb.

func (*EvaluationRepository) DeleteAllByUserID

func (r *EvaluationRepository) DeleteAllByUserID(ctx context.Context, userID string) error

Delete deletes evaluations for a user.

func (*EvaluationRepository) DeleteByID

func (r *EvaluationRepository) DeleteByID(ctx context.Context, idHex string) error

DeleteByID deletes an evaluation by its ID.

func (*EvaluationRepository) FindAllByReqHash

func (r *EvaluationRepository) FindAllByReqHash(ctx context.Context, reqHash string) (flaggio.EvaluationList, error)

FindAllByReqHash returns all previous flag evaluations for a given request hash.

func (*EvaluationRepository) FindAllByUserID

func (r *EvaluationRepository) FindAllByUserID(ctx context.Context, userID string, search *string, offset, limit *int64) (*flaggio.EvaluationResults, error)

FindAllByUserID returns all previous flag evaluations for a given user ID.

func (*EvaluationRepository) FindByID

func (r *EvaluationRepository) FindByID(ctx context.Context, idHex string) (*flaggio.Evaluation, error)

FindByID returns a previous flag evaluation by its ID.

func (*EvaluationRepository) FindByReqHashAndFlagKey

func (r *EvaluationRepository) FindByReqHashAndFlagKey(ctx context.Context, reqHash, flagKey string) (*flaggio.Evaluation, error)

FindByReqHashAndFlagKey returns a previous flag evaluation for a given request hash and flag key.

func (*EvaluationRepository) ReplaceAll

func (r *EvaluationRepository) ReplaceAll(ctx context.Context, userID, reqHash string, evals flaggio.EvaluationList) error

ReplaceAll creates or replaces evaluations for a combination of user and request hash.

func (*EvaluationRepository) ReplaceOne

func (r *EvaluationRepository) ReplaceOne(ctx context.Context, userID string, eval *flaggio.Evaluation) error

ReplaceOne creates or replaces one evaluation for a user ID.

type FlagRepository

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

FlagRepository implements repository.Flag interface using mongodb.

func (*FlagRepository) Create

func (r *FlagRepository) Create(ctx context.Context, f flaggio.NewFlag) (string, error)

Create creates a new flag.

func (*FlagRepository) Delete

func (r *FlagRepository) Delete(ctx context.Context, idHex string) error

Delete deletes a flag.

func (*FlagRepository) FindAll

func (r *FlagRepository) FindAll(ctx context.Context, search *string, offset, limit *int64) (*flaggio.FlagResults, error)

FindAll returns a list of flags, based on an optional offset and limit.

func (*FlagRepository) FindByID

func (r *FlagRepository) FindByID(ctx context.Context, idHex string) (*flaggio.Flag, error)

FindByID returns a flag that has a given ID.

func (*FlagRepository) FindByKey

func (r *FlagRepository) FindByKey(ctx context.Context, key string) (*flaggio.Flag, error)

FindByKey returns a flag that has a given key.

func (*FlagRepository) Update

func (r *FlagRepository) Update(ctx context.Context, idHex string, f flaggio.UpdateFlag) error

Update updates a flag.

type RuleRepository

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

RuleRepository implements repository.Rule interface using mongodb.

func (*RuleRepository) CreateFlagRule

func (r *RuleRepository) CreateFlagRule(ctx context.Context, flagIDHex string, fr flaggio.NewFlagRule) (string, error)

CreateFlagRule creates a new rule under a flag.

func (*RuleRepository) CreateSegmentRule

func (r *RuleRepository) CreateSegmentRule(ctx context.Context, segmentIDHex string, fr flaggio.NewSegmentRule) (string, error)

CreateSegmentRule creates a new rule under a segment.

func (*RuleRepository) DeleteFlagRule

func (r *RuleRepository) DeleteFlagRule(ctx context.Context, flagIDHex, idHex string) error

DeleteFlagRule deletes a rule under a flag.

func (*RuleRepository) DeleteSegmentRule

func (r *RuleRepository) DeleteSegmentRule(ctx context.Context, segmentIDHex, idHex string) error

DeleteSegmentRule deletes a rule under a segment.

func (*RuleRepository) FindFlagRuleByID

func (r *RuleRepository) FindFlagRuleByID(ctx context.Context, flagIDHex, idHex string) (*flaggio.FlagRule, error)

FindFlagRuleByID returns a flag rule that has a given ID.

func (*RuleRepository) FindSegmentRuleByID

func (r *RuleRepository) FindSegmentRuleByID(ctx context.Context, segmentIDHex, idHex string) (*flaggio.SegmentRule, error)

FindSegmentRuleByID returns a segment rule that has a given ID.

func (*RuleRepository) UpdateFlagRule

func (r *RuleRepository) UpdateFlagRule(ctx context.Context, flagIDHex, idHex string, fr flaggio.UpdateFlagRule) error

UpdateFlagRule updates a rule under a flag.

func (*RuleRepository) UpdateSegmentRule

func (r *RuleRepository) UpdateSegmentRule(ctx context.Context, segmentIDHex, idHex string, fr flaggio.UpdateSegmentRule) error

UpdateSegmentRule updates a rule under a segment.

type SegmentRepository

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

SegmentRepository implements repository.Segment interface using mongodb.

func (*SegmentRepository) Create

Create creates a new segment.

func (*SegmentRepository) Delete

func (r *SegmentRepository) Delete(ctx context.Context, idHex string) error

Delete deletes a segment.

func (*SegmentRepository) FindAll

func (r *SegmentRepository) FindAll(ctx context.Context, offset, limit *int64) ([]*flaggio.Segment, error)

FindAll returns a list of segments, based on an optional offset and limit.

func (*SegmentRepository) FindByID

func (r *SegmentRepository) FindByID(ctx context.Context, idHex string) (*flaggio.Segment, error)

FindByID returns a segment that has a given ID.

func (*SegmentRepository) Update

Update updates a segment.

type UserRepository

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

UserRepository implements repository.Flag interface using mongodb.

func (*UserRepository) Delete

func (r *UserRepository) Delete(ctx context.Context, userID string) error

Delete deletes a user.

func (*UserRepository) FindAll

func (r *UserRepository) FindAll(ctx context.Context, search *string, offset, limit *int64) (*flaggio.UserResults, error)

FindAll returns a list of users, based on an optional offset and limit.

func (*UserRepository) FindByID

func (r *UserRepository) FindByID(ctx context.Context, id string) (*flaggio.User, error)

FindByID returns a user by its id.

func (*UserRepository) Replace

func (r *UserRepository) Replace(ctx context.Context, userID string, userCtx flaggio.UserContext) error

Replace creates or updates a user.

type VariantRepository

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

VariantRepository implements repository.Variant interface using mongodb.

func (*VariantRepository) Create

func (r *VariantRepository) Create(ctx context.Context, flagIDHex string, v flaggio.NewVariant) (string, error)

Create creates a new variant under a flag.

func (*VariantRepository) Delete

func (r *VariantRepository) Delete(ctx context.Context, flagIDHex, idHex string) error

Delete deletes a variant under a flag.

func (*VariantRepository) FindByID

func (r *VariantRepository) FindByID(ctx context.Context, flagIDHex, idHex string) (*flaggio.Variant, error)

FindByID returns a variant that has a given ID.

func (*VariantRepository) Update

func (r *VariantRepository) Update(ctx context.Context, flagIDHex, idHex string, v flaggio.UpdateVariant) error

Update updates a variant under a flag.

Jump to

Keyboard shortcuts

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