Documentation ¶
Overview ¶
Package postgresstore implements a store that saves all the segments in a PostgreSQL database. It requires PostgreSQL >= 9.5 for "ON CONFLICT DO UPDATE" support.
Index ¶
- Constants
- func RegisterFlags()
- type Batch
- func (a Batch) CreateLink(link *cs.Link) (*types.Bytes32, error)
- func (a Batch) DeleteValue(key []byte) ([]byte, error)
- func (a Batch) FindSegments(filter *store.SegmentFilter) (cs.SegmentSlice, error)
- func (a Batch) GetEvidences(linkHash *types.Bytes32) (*cs.Evidences, error)
- func (a Batch) GetMapIDs(filter *store.MapFilter) ([]string, error)
- func (a Batch) GetSegment(linkHash *types.Bytes32) (*cs.Segment, error)
- func (a Batch) GetValue(key []byte) ([]byte, error)
- func (a Batch) SetValue(key []byte, value []byte) error
- func (b *Batch) Write() error
- type Config
- type Info
- type Store
- func (a *Store) AddEvidence(linkHash *types.Bytes32, evidence *cs.Evidence) error
- func (a *Store) AddStoreEventChannel(eventChan chan *store.Event)
- func (a *Store) Close() error
- func (a *Store) Create() error
- func (a *Store) CreateLink(link *cs.Link) (*types.Bytes32, error)
- func (a Store) DeleteValue(key []byte) ([]byte, error)
- func (a *Store) Drop() error
- func (a Store) FindSegments(filter *store.SegmentFilter) (cs.SegmentSlice, error)
- func (a Store) GetEvidences(linkHash *types.Bytes32) (*cs.Evidences, error)
- func (a *Store) GetInfo() (interface{}, error)
- func (a Store) GetMapIDs(filter *store.MapFilter) ([]string, error)
- func (a Store) GetSegment(linkHash *types.Bytes32) (*cs.Segment, error)
- func (a Store) GetValue(key []byte) ([]byte, error)
- func (a *Store) NewBatch() (store.Batch, error)
- func (a *Store) Prepare() error
- func (a Store) SetValue(key []byte, value []byte) error
Constants ¶
const ( // Name is the name set in the store's information. Name = "postgres" // Description is the description set in the store's information. Description = "Stratumn PostgreSQL Store" // DefaultURL is the default URL of the database. DefaultURL = "postgres://postgres@postgres/postgres?sslmode=disable" )
Variables ¶
This section is empty.
Functions ¶
func RegisterFlags ¶
func RegisterFlags()
RegisterFlags registers the flags used by InitializeWithFlags.
Types ¶
type Batch ¶
type Batch struct {
// contains filtered or unexported fields
}
Batch is the type that implements github.com/stratumn/sdk/store.Batch.
func (Batch) CreateLink ¶
CreateLink implements github.com/stratumn/sdk/store.Adapter.CreateLink.
func (Batch) DeleteValue ¶
DeleteValue implements github.com/stratumn/sdk/store.KeyValueStore.DeleteValue.
func (Batch) FindSegments ¶
func (a Batch) FindSegments(filter *store.SegmentFilter) (cs.SegmentSlice, error)
FindSegments implements github.com/stratumn/sdk/store.SegmentReader.FindSegments.
func (Batch) GetEvidences ¶
GetEvidences implements github.com/stratumn/sdk/store.EvidenceReader.GetEvidences.
func (Batch) GetMapIDs ¶
GetMapIDs implements github.com/stratumn/sdk/store.SegmentReader.GetMapIDs.
func (Batch) GetSegment ¶
GetSegment implements github.com/stratumn/sdk/store.SegmentReader.GetSegment.
type Config ¶
type Config struct { // A version string that will be set in the store's information. Version string // A git commit hash that will be set in the store's information. Commit string // The URL of the PostgreSQL database, such as // "postgres://postgres@localhost/store?sslmode=disable". URL string }
Config contains configuration options for the store.
type Info ¶
type Info struct { Name string `json:"name"` Description string `json:"description"` Version string `json:"version"` Commit string `json:"commit"` }
Info is the info returned by GetInfo.
type Store ¶
type Store struct {
// contains filtered or unexported fields
}
Store is the type that implements github.com/stratumn/sdk/store.Adapter.
func Initialize ¶
Initialize initializes a postgres store adapter
func InitializeWithFlags ¶
InitializeWithFlags should be called after RegisterFlags and flag.Parse to intialize a postgres adapter using flag values.
func (*Store) AddEvidence ¶
AddEvidence implements github.com/stratumn/sdk/store.EvidenceWriter.AddEvidence.
func (*Store) AddStoreEventChannel ¶
AddStoreEventChannel implements github.com/stratumn/sdk/store.Adapter.AddStoreEventChannel
func (*Store) CreateLink ¶
CreateLink implements github.com/stratumn/sdk/store.LinkWriter.CreateLink.
func (Store) DeleteValue ¶
DeleteValue implements github.com/stratumn/sdk/store.KeyValueStore.DeleteValue.
func (Store) FindSegments ¶
func (a Store) FindSegments(filter *store.SegmentFilter) (cs.SegmentSlice, error)
FindSegments implements github.com/stratumn/sdk/store.SegmentReader.FindSegments.
func (Store) GetEvidences ¶
GetEvidences implements github.com/stratumn/sdk/store.EvidenceReader.GetEvidences.
func (Store) GetMapIDs ¶
GetMapIDs implements github.com/stratumn/sdk/store.SegmentReader.GetMapIDs.
func (Store) GetSegment ¶
GetSegment implements github.com/stratumn/sdk/store.SegmentReader.GetSegment.