resourceStore

package
v1.24.3 Latest Latest
Warning

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

Go to latest
Published: Apr 14, 2025 License: MIT Imports: 11 Imported by: 4

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type IResource

type IResource interface {
	GetResourceBase() *ResourceBase
}

IResource is an interface that any resource can implement

type JournalMaxClock

type JournalMaxClock struct {
	MaxClock uint64 `json:"maxClock"`
}

type PostgresCommandHelper

type PostgresCommandHelper struct {
}

PostgresCommandHelper handles query building using pgx and named parameters.

func (*PostgresCommandHelper) GetHealthCheckCommand

func (p *PostgresCommandHelper) GetHealthCheckCommand() string

func (*PostgresCommandHelper) GetInsertResourceWithJournalCommand

func (p *PostgresCommandHelper) GetInsertResourceWithJournalCommand(resource IResource, resourceJson []byte, partitionName string) (string, pgx.NamedArgs)

func (*PostgresCommandHelper) GetJournalChangesCommand

func (p *PostgresCommandHelper) GetJournalChangesCommand(clock, limit int64) (string, pgx.NamedArgs)

func (*PostgresCommandHelper) GetJournalMaxClockCommand

func (p *PostgresCommandHelper) GetJournalMaxClockCommand() string

func (*PostgresCommandHelper) GetResourceByIdCommand

func (p *PostgresCommandHelper) GetResourceByIdCommand(id string) (string, pgx.NamedArgs)

func (*PostgresCommandHelper) GetResourcesByOwnerIdCommand

func (p *PostgresCommandHelper) GetResourcesByOwnerIdCommand(ownerId string) (string, pgx.NamedArgs)

func (*PostgresCommandHelper) GetUpdateResourceWithJournalCommand

func (p *PostgresCommandHelper) GetUpdateResourceWithJournalCommand(resource IResource, versionToUpdate uint, resourceJson []byte, partitionName string) (string, pgx.NamedArgs)

type PostgresResourceStoreWithJournal

type PostgresResourceStoreWithJournal[R any] struct {
	Cmds *PostgresCommandHelper
	// contains filtered or unexported fields
}

PostgresResourceStoreWithJournal is the Go equivalent of the C# PostgresResourceStoreWithJournal class

func NewPostgresResourceStoreWithJournal

func NewPostgresResourceStoreWithJournal[R any](configuration *viper.Viper, logger *logrus.Logger) (*PostgresResourceStoreWithJournal[R], error)

private methods below here

func (*PostgresResourceStoreWithJournal[R]) CreateResource

func (store *PostgresResourceStoreWithJournal[R]) CreateResource(resource IResource) (IResource, int, error)

CreateResource creates a new resource

func (*PostgresResourceStoreWithJournal[R]) GetById

func (store *PostgresResourceStoreWithJournal[R]) GetById(id string, resource *R) (int, error)

GetById retrieves a resource by its ID

func (*PostgresResourceStoreWithJournal[R]) GetByOwnerId

func (store *PostgresResourceStoreWithJournal[R]) GetByOwnerId(ownerId string, resources *[]R) (int, error)

GetByOwner retrieves resources by owner ID

func (*PostgresResourceStoreWithJournal[R]) GetJournalChanges

func (store *PostgresResourceStoreWithJournal[R]) GetJournalChanges(clock int64, limit int64, journalEntries *[]ResourceJournalEntry) error

GetJournalChanges retrieves changes >= clock up to limit entries We support >= clock to allow for fetching a specific clock entry (e.g. clock = 25, limit = 1) when the client has the clock value for that one and needs to fetch it again for some reason.

func (*PostgresResourceStoreWithJournal[R]) GetJournalMaxClock

func (store *PostgresResourceStoreWithJournal[R]) GetJournalMaxClock(maxClock *uint64) error

func (*PostgresResourceStoreWithJournal[R]) HealthCheck

func (store *PostgresResourceStoreWithJournal[R]) HealthCheck() error

HealthCheck performs a health check on the database

func (*PostgresResourceStoreWithJournal[R]) UpdateResource

func (store *PostgresResourceStoreWithJournal[R]) UpdateResource(resource IResource, ownerId string, resourceId string) (IResource, int, error)

CreateResource creates a new resource

type ResourceBase

type ResourceBase struct {
	Id        string    `json:"id"`
	OwnerId   string    `json:"ownerId"`
	Version   uint      `json:"version"`
	CreatedAt time.Time `json:"createdAt"`
	UpdatedAt time.Time `json:"updatedAt"`
	Deleted   bool      `json:"deleted"`
}

func (*ResourceBase) GetResourceBase

func (r *ResourceBase) GetResourceBase() *ResourceBase

type ResourceJournalEntry

type ResourceJournalEntry struct {
	Clock         uint64          `json:"clock"`
	Resource      json.RawMessage `json:"resource"`
	CreatedAt     time.Time       `json:"createdAt"`
	PartitionName string          `json:"partitionName"`
}

Jump to

Keyboard shortcuts

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