Documentation
¶
Index ¶
- type IResource
- type JournalMaxClock
- type PostgresCommandHelper
- func (p *PostgresCommandHelper) GetHealthCheckCommand() string
- func (p *PostgresCommandHelper) GetInsertResourceWithJournalCommand(resource IResource, resourceJson []byte, partitionName string) (string, pgx.NamedArgs)
- func (p *PostgresCommandHelper) GetJournalChangesCommand(clock, limit int64) (string, pgx.NamedArgs)
- func (p *PostgresCommandHelper) GetJournalMaxClockCommand() string
- func (p *PostgresCommandHelper) GetResourceByIdCommand(id string) (string, pgx.NamedArgs)
- func (p *PostgresCommandHelper) GetResourcesByOwnerIdCommand(ownerId string) (string, pgx.NamedArgs)
- func (p *PostgresCommandHelper) GetUpdateResourceWithJournalCommand(resource IResource, versionToUpdate uint, resourceJson []byte, ...) (string, pgx.NamedArgs)
- type PostgresResourceStoreWithJournal
- func (store *PostgresResourceStoreWithJournal[R]) CreateResource(resource IResource) (IResource, int, error)
- func (store *PostgresResourceStoreWithJournal[R]) GetById(id string, resource *R) (int, error)
- func (store *PostgresResourceStoreWithJournal[R]) GetByOwnerId(ownerId string, resources *[]R) (int, error)
- func (store *PostgresResourceStoreWithJournal[R]) GetJournalChanges(clock int64, limit int64, journalEntries *[]ResourceJournalEntry) error
- func (store *PostgresResourceStoreWithJournal[R]) GetJournalMaxClock(maxClock *uint64) error
- func (store *PostgresResourceStoreWithJournal[R]) HealthCheck() error
- func (store *PostgresResourceStoreWithJournal[R]) UpdateResource(resource IResource, ownerId string, resourceId string) (IResource, int, error)
- type ResourceBase
- type ResourceJournalEntry
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 (*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 ¶
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