180
GitHub - mercari/datastore: (AE|Cloud) Datastore Wrapper
source link: https://github.com/mercari/datastore
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
Datastore Wrapper
(AppEngine | Cloud) Datastore wrapper for Go
Simple. Happy. Respect standard library.
$ go get -u go.mercari.io/datastore
Feature
- Wrap
google.golang.org/appengine/datastore
andcloud.google.com/go/datastore
- keep key behavior
- align to
cloud.google.com/go/datastore
first
- Re-implement datastore package
- Re-implement datastore.SaveStruct & LoadStruct
- Ignore unmapped property
- Add PropertyTranslator interface
- Convert types like mytime.Unix to time.Time and reverse it
- Rename property like CreatedAt to createdAt or created_at and reverse it
- Re-implement PropertyLoadSaver
- Pass context.Context to Save & Load method
- Add retry feature to each RPC
- e.g. Retry AllocateID when it failed
- Add middleware layer
- About...
- Local Cache
- AE Memcache
- Logging
- Retry
- etc...
- Easy to ON/OFF switching
- About...
- Add some useful methods
aedatastore/TransactionContext
DON'T
- have utility functions
- support firestore
Restriction
aedatastore
package- When using slice of struct, MUST specified
datastore:",flatten"
option.- original (ae & cloud) datastore.SaveStruct have different behaviors.
- see aeprodtest/main.go
/api/test3
- When using slice of struct, MUST specified
Committers
- Masahiro Wakame (@vvakame)
Contribution
Please read the CLA below carefully before submitting your contribution.
Setup environment & Run tests
- requirements
- gcloud sdk
gcloud components install app-engine-go
gcloud components install beta cloud-datastore-emulator
- gcloud sdk
- Testing in local
$ ./setup.sh # exec once
$ ./serve.sh # exec in background
$ ./test.sh
- Testing with Circle CI CLI
$ circleci build
License
Copyright 2017 Mercari, Inc.
Licensed under the MIT License.
Recommend
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK