patcher

package module
v0.6.4 Latest Latest
Warning

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

Go to latest
Published: Nov 21, 2024 License: MIT Imports: 22 Imported by: 0

README

patcher

The patcher repo contains types and utilitys to be used when mutating database objects and optionally tracking these data change events in a tracking table.

Documentation

Overview

package patcher provides functionality to patch resources

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ProcessEvent added in v0.6.1

func ProcessEvent(processName string) string

func UserEvent added in v0.6.1

func UserEvent(ctx context.Context) string

func UserProcessEvent added in v0.6.1

func UserProcessEvent(ctx context.Context, processName string) string

Types

type DataChangeEvent

type DataChangeEvent struct {
	TableName   accesstypes.Resource `spanner:"TableName"`
	RowID       string               `spanner:"RowId"`
	EventTime   time.Time            `spanner:"EventTime"`
	EventSource string               `spanner:"EventSource"`
	ChangeSet   string               `spanner:"ChangeSet"`
}

type DiffElem

type DiffElem struct {
	Old any
	New any
}

type Mutation added in v0.6.0

type Mutation struct {
	TableName accesstypes.Resource
	RowStruct RowStruct
	PatchSet  *patchset.PatchSet
}

type PostgresPatcher

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

func NewPostgresPatcher

func NewPostgresPatcher() *PostgresPatcher

func (PostgresPatcher) AllColumns added in v0.3.0

func (p PostgresPatcher) AllColumns(databaseType any) (string, error)

AllColumns returns the database struct tags for all fields in databaseType.

func (PostgresPatcher) Diff

func (p PostgresPatcher) Diff(old any, patchSet *patchset.PatchSet) (map[accesstypes.Field]DiffElem, error)

Diff returns a map of fields that have changed between old and patchSet.

func (PostgresPatcher) PatchSetColumns added in v0.0.4

func (p PostgresPatcher) PatchSetColumns(patchSet *patchset.PatchSet, databaseType any) (string, error)

PatchSetColumns returns the database struct tags for the field in databaseType if it exists in patchSet.

func (PostgresPatcher) Resolve

func (p PostgresPatcher) Resolve(patchSet *patchset.PatchSet, databaseType any) (map[string]any, error)

Resolve returns a map with the keys set to the database struct tags found on databaseType, and the values set to the values in patchSet.

func (PostgresPatcher) ViewableColumns added in v0.0.4

func (p PostgresPatcher) ViewableColumns(ctx context.Context, columnSet columnset.ColumnSet, databaseType any) (string, error)

ViewableColumns returns the database struct tags for the fields in databaseType that the user has access to view.

func (*PostgresPatcher) WithDataChangeTableName

func (p *PostgresPatcher) WithDataChangeTableName(tableName string) *PostgresPatcher

type RowStruct

type RowStruct interface {
	New() any
	Type() any
}

func NewRowStruct

func NewRowStruct[T any](rowStruct T) RowStruct

type SpannerPatcher

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

func NewSpannerPatcher

func NewSpannerPatcher() *SpannerPatcher

func (SpannerPatcher) AllColumns added in v0.3.0

func (p SpannerPatcher) AllColumns(databaseType any) (string, error)

AllColumns returns the database struct tags for all fields in databaseType.

func (*SpannerPatcher) BufferDelete added in v0.5.0

func (p *SpannerPatcher) BufferDelete(txn *spanner.ReadWriteTransaction, mutation *Mutation) error

func (*SpannerPatcher) BufferDeleteWithDataChangeEvent added in v0.5.0

func (p *SpannerPatcher) BufferDeleteWithDataChangeEvent(ctx context.Context, txn *spanner.ReadWriteTransaction, eventSource string, mutation *Mutation) error

func (*SpannerPatcher) BufferInsert added in v0.5.0

func (p *SpannerPatcher) BufferInsert(txn *spanner.ReadWriteTransaction, mutation *Mutation) error

func (*SpannerPatcher) BufferInsertOrUpdate added in v0.5.0

func (p *SpannerPatcher) BufferInsertOrUpdate(txn *spanner.ReadWriteTransaction, mutation *Mutation) error

func (*SpannerPatcher) BufferInsertOrUpdateWithDataChangeEvent added in v0.5.0

func (p *SpannerPatcher) BufferInsertOrUpdateWithDataChangeEvent(txn *spanner.ReadWriteTransaction, eventSource string, mutation *Mutation) error

func (*SpannerPatcher) BufferInsertWithDataChangeEvent added in v0.5.0

func (p *SpannerPatcher) BufferInsertWithDataChangeEvent(txn *spanner.ReadWriteTransaction, eventSource string, mutation *Mutation) error

func (*SpannerPatcher) BufferUpdate added in v0.5.0

func (p *SpannerPatcher) BufferUpdate(txn *spanner.ReadWriteTransaction, mutation *Mutation) error

func (*SpannerPatcher) BufferUpdateWithDataChangeEvent added in v0.5.0

func (p *SpannerPatcher) BufferUpdateWithDataChangeEvent(ctx context.Context, txn *spanner.ReadWriteTransaction, eventSource string, mutation *Mutation) error

func (*SpannerPatcher) Delete

func (p *SpannerPatcher) Delete(ctx context.Context, s *spanner.Client, mutation *Mutation) error

func (*SpannerPatcher) DeleteWithDataChangeEvent

func (p *SpannerPatcher) DeleteWithDataChangeEvent(ctx context.Context, s *spanner.Client, eventSource string, mutation *Mutation) error

func (SpannerPatcher) Diff

func (p SpannerPatcher) Diff(old any, patchSet *patchset.PatchSet) (map[accesstypes.Field]DiffElem, error)

Diff returns a map of fields that have changed between old and patchSet.

func (*SpannerPatcher) Insert

func (p *SpannerPatcher) Insert(ctx context.Context, s *spanner.Client, mutation *Mutation) error

func (*SpannerPatcher) InsertOrUpdate added in v0.5.0

func (p *SpannerPatcher) InsertOrUpdate(ctx context.Context, s *spanner.Client, mutation *Mutation) error

func (*SpannerPatcher) InsertOrUpdateWithDataChangeEvent added in v0.5.0

func (p *SpannerPatcher) InsertOrUpdateWithDataChangeEvent(ctx context.Context, s *spanner.Client, eventSource string, mutation *Mutation) error

func (*SpannerPatcher) InsertWithDataChangeEvent

func (p *SpannerPatcher) InsertWithDataChangeEvent(ctx context.Context, s *spanner.Client, eventSource string, mutation *Mutation) error

func (SpannerPatcher) PatchSetColumns added in v0.0.4

func (p SpannerPatcher) PatchSetColumns(patchSet *patchset.PatchSet, databaseType any) (string, error)

PatchSetColumns returns the database struct tags for the field in databaseType if it exists in patchSet.

func (SpannerPatcher) Resolve

func (p SpannerPatcher) Resolve(patchSet *patchset.PatchSet, databaseType any) (map[string]any, error)

Resolve returns a map with the keys set to the database struct tags found on databaseType, and the values set to the values in patchSet.

func (*SpannerPatcher) Update

func (p *SpannerPatcher) Update(ctx context.Context, s *spanner.Client, mutation *Mutation) error

func (*SpannerPatcher) UpdateWithDataChangeEvent

func (p *SpannerPatcher) UpdateWithDataChangeEvent(ctx context.Context, s *spanner.Client, eventSource string, mutation *Mutation) error

func (SpannerPatcher) ViewableColumns added in v0.0.4

func (p SpannerPatcher) ViewableColumns(ctx context.Context, columnSet columnset.ColumnSet, databaseType any) (string, error)

ViewableColumns returns the database struct tags for the fields in databaseType that the user has access to view.

func (*SpannerPatcher) WithDataChangeTableName

func (p *SpannerPatcher) WithDataChangeTableName(tableName string) *SpannerPatcher

Jump to

Keyboard shortcuts

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