generated from RTradeLtd/repo-template
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #14 from RTradeLtd/sql
fork go-ds-sql (WIP)
- Loading branch information
Showing
13 changed files
with
1,569 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
# Golang CircleCI 2.0 configuration file | ||
# | ||
# Check https://circleci.com/docs/2.0/language-go/ for more details | ||
version: 2 | ||
jobs: | ||
build: | ||
docker: | ||
# specify the version | ||
- image: circleci/golang:1.14.2 | ||
|
||
# Specify service dependencies here if necessary | ||
# CircleCI maintains a library of pre-built images | ||
# documented at https://circleci.com/docs/2.0/circleci-images/ | ||
- image: circleci/postgres:latest | ||
environment: | ||
POSTGRES_HOST_AUTH_METHOD: trust | ||
POSTGRES_DB: datastores | ||
|
||
|
||
#### TEMPLATE_NOTE: go expects specific checkout path representing url | ||
#### expecting it in the form of | ||
#### /go/src/github.com/circleci/go-tool | ||
#### /go/src/bitbucket.org/circleci/go-tool | ||
working_directory: /go/src/github.com/{{ORG_NAME}}/{{REPO_NAME}} | ||
steps: | ||
- checkout | ||
|
||
# specify any bash command here prefixed with `run: ` | ||
- run: go get -v -t -d ./... | ||
- run: go test -v -race -short -coverprofile=coverage.txt ./... | ||
- run: bash <(curl -s https://codecov.io/bash) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,44 @@ | ||
# go-datastores | ||
|
||
`go-datastores` is a collection of a variety of IPFS datastores to be used by TemporalX in a single monorepo for easy maintenance. If you are a user of TemporalX and want to use a datastore we dont currently support, you can submit PRs to this repository and they will be included in TemporalX's configuration. | ||
`go-datastores` is a collection of a variety of IPFS datastores to be used by TemporalX in a single monorepo for easy maintenance. A majority of these datastores are forked from upstream repositories, with minor modifications to faciltiate easier integration with TemporalX, along with performance improvements and optimizations where possible. Additionally it allows us to pull in all datastores we need from a single repository. | ||
|
||
If you are a user of TemporalX and want to be able to use datastores that we do not yet support, you can submit a PR and we'll enable usage of the datastore within our next release | ||
|
||
# supported datastores | ||
|
||
## full support | ||
|
||
The following datastores are marked as "fully supported" and should have no problems with usage outside of edge case bugs | ||
|
||
* badger | ||
* leveldb | ||
* sql | ||
* includes a postgresql implementation | ||
* note this may have unknown issues | ||
|
||
## partial support | ||
|
||
The following datastores are marked as "partially supported" and may have problems with usage, namely related to query functionality. | ||
|
||
* pebble | ||
* functions supported: | ||
* Get | ||
* GetSize | ||
* Delete | ||
* Put | ||
* Has | ||
* problematic: | ||
* Query | ||
* nutsdb | ||
* functions supported: | ||
* Get | ||
* GetSize | ||
* Delete | ||
* Put | ||
* Has | ||
* problematic: | ||
* Query | ||
|
||
# license | ||
|
||
Some of the datastores were forked from upstream, and as such are licensed under the upstream licenses, any forked datastores will have a `LICENSE.orig` in their folder to indicate the corresponding upstream license. Any datastores without the `LICENSE.orig` in their folders are licensed under AGPL-v3 license, for which you can find in the `LICENSE` file in the repository root. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
The MIT License | ||
|
||
Copyright (c) 2016 Łukasz Magiera | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in | ||
all copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | ||
THE SOFTWARE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
The MIT License (MIT) | ||
|
||
Copyright (c) 2016 Jeromy Johnson | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in | ||
all copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | ||
THE SOFTWARE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
package sqlds | ||
|
||
import ( | ||
"context" | ||
|
||
ds "github.com/ipfs/go-datastore" | ||
"go.uber.org/multierr" | ||
) | ||
|
||
type op struct { | ||
delete bool | ||
value []byte | ||
} | ||
|
||
type batch struct { | ||
ds *Datastore | ||
ops map[ds.Key]op | ||
} | ||
|
||
// Batch creates a set of deferred updates to the database. | ||
// Since SQL does not support a true batch of updates, | ||
// operations are buffered and then executed sequentially | ||
// over a single connection when Commit is called. | ||
func (d *Datastore) Batch() (ds.Batch, error) { | ||
return &batch{ | ||
ds: d, | ||
ops: make(map[ds.Key]op), | ||
}, nil | ||
} | ||
|
||
func (bt *batch) Put(key ds.Key, val []byte) error { | ||
bt.ops[key] = op{value: val} | ||
return nil | ||
} | ||
|
||
func (bt *batch) Delete(key ds.Key) error { | ||
bt.ops[key] = op{delete: true} | ||
return nil | ||
} | ||
|
||
func (bt *batch) Commit() error { | ||
return bt.CommitContext(context.Background()) | ||
} | ||
|
||
func (bt *batch) CommitContext(ctx context.Context) error { | ||
conn, err := bt.ds.db.Conn(ctx) | ||
if err != nil { | ||
return err | ||
} | ||
|
||
for k, op := range bt.ops { | ||
if op.delete { | ||
_, err = conn.ExecContext(ctx, bt.ds.queries.Delete(), k.String()) | ||
} else { | ||
_, err = conn.ExecContext(ctx, bt.ds.queries.Put(), k.String(), op.value) | ||
} | ||
if err != nil { | ||
break | ||
} | ||
} | ||
|
||
return multierr.Combine(err, conn.Close()) | ||
} |
Oops, something went wrong.