datastore

package
v0.2.134 Latest Latest
Warning

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

Go to latest
Published: Dec 25, 2019 License: BSD-2-Clause Imports: 4 Imported by: 0

README

Datastore

標準メソッドとカスタムメソッドのデータの永続化に関する共通部分を抽象化するものである。

Documentation

Overview

Example

func SomeEndpoint(ctx context.COntext, req SomeRequest) error {
	// validation

	datastore.Lock(req.Key)
	defer datastore.Unlock(req.Key)

	tx := transaction.Begin()
	defer tx.Rollback()

	// API Process

	tx.Done()

	return nil
}

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DefaultErrorMessage

func DefaultErrorMessage(err error) string

func IsNotFound

func IsNotFound(err error) bool

Types

type Datastore

type Datastore interface {
	AddPrefix(prefix string) Datastore

	List(f func(length int) []proto.Message) error

	// if result is empty, set pb as nil.
	Get(key string, pb proto.Message) error

	// update process requires locking in advance
	Apply(key string, pb proto.Message) error
	Delete(key string) error

	Lock(key string) bool
	Unlock(key string) bool
	IsLocked(key string) bool
}

type NotFound

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

func NewNotFound

func NewNotFound(key string) *NotFound

func (NotFound) Error

func (e NotFound) Error() string

func (NotFound) IsNotFound

func (e NotFound) IsNotFound() bool

type NotFoundError

type NotFoundError interface {
	IsNotFound() bool

	Error() string
}

type Test

type Test struct {
	Name                 string   `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"`
	XXX_NoUnkeyedLiteral struct{} `json:"-"`
	XXX_unrecognized     []byte   `json:"-"`
	XXX_sizecache        int32    `json:"-"`
}

func (*Test) Descriptor

func (*Test) Descriptor() ([]byte, []int)

func (*Test) GetName

func (m *Test) GetName() string

func (*Test) ProtoMessage

func (*Test) ProtoMessage()

func (*Test) Reset

func (m *Test) Reset()

func (*Test) String

func (m *Test) String() string

func (*Test) XXX_DiscardUnknown

func (m *Test) XXX_DiscardUnknown()

func (*Test) XXX_Marshal

func (m *Test) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*Test) XXX_Merge

func (m *Test) XXX_Merge(src proto.Message)

func (*Test) XXX_Size

func (m *Test) XXX_Size() int

func (*Test) XXX_Unmarshal

func (m *Test) XXX_Unmarshal(b []byte) error

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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