Skip to content

Commit

Permalink
Merge pull request #26 from rabee-inc/feature/firestore_multi_db
Browse files Browse the repository at this point in the history
FirestoreをMultiDBに対応
  • Loading branch information
aikizoku authored Sep 19, 2023
2 parents 8b97224 + e020b35 commit 279f8d1
Show file tree
Hide file tree
Showing 5 changed files with 119 additions and 175 deletions.
22 changes: 0 additions & 22 deletions cloudfirestore/client.go

This file was deleted.

36 changes: 18 additions & 18 deletions cloudfirestore/convertible_batch_getter_impl.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,36 +16,36 @@ type convertibleBatchGetterItem[D any] struct {
OnEmptyFunc func()
}

func (a *convertibleBatchGetterItem[D]) After(f func(D)) ConvertibleBatchGetterItem[D] {
a.AfterFunc = f
return a
func (cbg *convertibleBatchGetterItem[D]) After(f func(D)) ConvertibleBatchGetterItem[D] {
cbg.AfterFunc = f
return cbg
}

func (a *convertibleBatchGetterItem[D]) EmitAfter(d D) {
if a.AfterFunc != nil {
a.AfterFunc(d)
func (cbg *convertibleBatchGetterItem[D]) EmitAfter(d D) {
if cbg.AfterFunc != nil {
cbg.AfterFunc(d)
}
}

func (a *convertibleBatchGetterItem[D]) RemoveAfter() ConvertibleBatchGetterItem[D] {
a.AfterFunc = nil
return a
func (cbg *convertibleBatchGetterItem[D]) RemoveAfter() ConvertibleBatchGetterItem[D] {
cbg.AfterFunc = nil
return cbg
}

func (a *convertibleBatchGetterItem[D]) OnEmpty(f func()) ConvertibleBatchGetterItem[D] {
a.OnEmptyFunc = f
return a
func (cbg *convertibleBatchGetterItem[D]) OnEmpty(f func()) ConvertibleBatchGetterItem[D] {
cbg.OnEmptyFunc = f
return cbg
}

func (a *convertibleBatchGetterItem[D]) EmitEmpty() {
if a.OnEmptyFunc != nil {
a.OnEmptyFunc()
func (cbg *convertibleBatchGetterItem[D]) EmitEmpty() {
if cbg.OnEmptyFunc != nil {
cbg.OnEmptyFunc()
}
}

func (a *convertibleBatchGetterItem[D]) RemoveOnEmpty() ConvertibleBatchGetterItem[D] {
a.OnEmptyFunc = nil
return a
func (cbg *convertibleBatchGetterItem[D]) RemoveOnEmpty() ConvertibleBatchGetterItem[D] {
cbg.OnEmptyFunc = nil
return cbg
}

type convertibleBatchGetter[S, D any] struct {
Expand Down
6 changes: 3 additions & 3 deletions cloudfirestore/helper.go
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ func GetByQuery(ctx context.Context, query firestore.Query, dst any) (bool, erro
}
defer it.Stop()
dsnp, err := it.Next()
if err == iterator.Done {
if errors.Is(err, iterator.Done) {
return false, nil
}
if err != nil {
Expand Down Expand Up @@ -197,7 +197,7 @@ func ListByQuery(ctx context.Context, query firestore.Query, dsts any) error {
rrt := rv.Type().Elem().Elem()
for {
dsnp, err := it.Next()
if err == iterator.Done {
if errors.Is(err, iterator.Done) {
break
}
if err != nil {
Expand Down Expand Up @@ -236,7 +236,7 @@ func ListByQueryCursor(ctx context.Context, query firestore.Query, limit int, cu
var lastDsnp *firestore.DocumentSnapshot
for {
dsnp, err := it.Next()
if err == iterator.Done {
if errors.Is(err, iterator.Done) {
break
}
if err != nil {
Expand Down
62 changes: 32 additions & 30 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,70 +3,72 @@ module github.com/rabee-inc/go-pkg
go 1.19

require (
cloud.google.com/go/bigquery v1.51.0
cloud.google.com/go/cloudtasks v1.10.0
cloud.google.com/go/firestore v1.9.0
cloud.google.com/go/pubsub v1.30.0
cloud.google.com/go/storage v1.30.1
cloud.google.com/go/bigquery v1.55.0
cloud.google.com/go/cloudtasks v1.12.1
cloud.google.com/go/firestore v1.13.0
cloud.google.com/go/pubsub v1.33.0
cloud.google.com/go/storage v1.33.0
firebase.google.com/go v3.13.0+incompatible
github.com/davecgh/go-spew v1.1.1
github.com/go-chi/chi v1.5.4
github.com/go-chi/chi v1.5.5
github.com/jszwec/csvutil v1.8.0
github.com/otiai10/opengraph v1.1.3
github.com/rs/xid v1.5.0
github.com/unrolled/render v1.6.0
github.com/vincent-petithory/dataurl v1.0.0
golang.org/x/exp v0.0.0-20220827204233-334a2380cb91
golang.org/x/sync v0.1.0
golang.org/x/text v0.9.0
google.golang.org/api v0.119.0
golang.org/x/exp v0.0.0-20230905200255-921286631fa9
golang.org/x/sync v0.3.0
golang.org/x/text v0.13.0
google.golang.org/api v0.141.0
gopkg.in/go-playground/assert.v1 v1.2.1
gopkg.in/go-playground/validator.v9 v9.31.0
gopkg.in/yaml.v3 v3.0.1
)

require (
cloud.google.com/go v0.110.0 // indirect
cloud.google.com/go/compute v1.19.0 // indirect
cloud.google.com/go v0.110.6 // indirect
cloud.google.com/go/compute v1.23.0 // indirect
cloud.google.com/go/compute/metadata v0.2.3 // indirect
cloud.google.com/go/iam v0.13.0 // indirect
cloud.google.com/go/longrunning v0.4.1 // indirect
cloud.google.com/go/iam v1.1.1 // indirect
cloud.google.com/go/longrunning v0.5.1 // indirect
github.com/andybalholm/brotli v1.0.4 // indirect
github.com/apache/arrow/go/v11 v11.0.0 // indirect
github.com/apache/arrow/go/v12 v12.0.0 // indirect
github.com/apache/thrift v0.16.0 // indirect
github.com/fsnotify/fsnotify v1.6.0 // indirect
github.com/go-playground/locales v0.14.1 // indirect
github.com/go-playground/universal-translator v0.18.1 // indirect
github.com/goccy/go-json v0.9.11 // indirect
github.com/golang/groupcache v0.0.0-20200121045136-8c9f03a8e57e // indirect
github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect
github.com/golang/protobuf v1.5.3 // indirect
github.com/golang/snappy v0.0.4 // indirect
github.com/google/flatbuffers v2.0.8+incompatible // indirect
github.com/google/go-cmp v0.5.9 // indirect
github.com/google/s2a-go v0.1.2 // indirect
github.com/google/uuid v1.3.0 // indirect
github.com/googleapis/enterprise-certificate-proxy v0.2.3 // indirect
github.com/googleapis/gax-go/v2 v2.8.0 // indirect
github.com/google/s2a-go v0.1.7 // indirect
github.com/google/uuid v1.3.1 // indirect
github.com/googleapis/enterprise-certificate-proxy v0.2.5 // indirect
github.com/googleapis/gax-go/v2 v2.12.0 // indirect
github.com/klauspost/asmfmt v1.3.2 // indirect
github.com/klauspost/compress v1.15.9 // indirect
github.com/klauspost/cpuid/v2 v2.0.9 // indirect
github.com/kr/text v0.2.0 // indirect
github.com/leodido/go-urn v1.2.3 // indirect
github.com/leodido/go-urn v1.2.4 // indirect
github.com/minio/asm2plan9s v0.0.0-20200509001527-cdd76441f9d8 // indirect
github.com/minio/c2goasm v0.0.0-20190812172519-36a3d3bbc4f3 // indirect
github.com/pierrec/lz4/v4 v4.1.15 // indirect
github.com/zeebo/xxh3 v1.0.2 // indirect
go.opencensus.io v0.24.0 // indirect
golang.org/x/crypto v0.1.0 // indirect
golang.org/x/mod v0.8.0 // indirect
golang.org/x/net v0.9.0 // indirect
golang.org/x/oauth2 v0.7.0 // indirect
golang.org/x/sys v0.7.0 // indirect
golang.org/x/crypto v0.13.0 // indirect
golang.org/x/mod v0.12.0 // indirect
golang.org/x/net v0.15.0 // indirect
golang.org/x/oauth2 v0.12.0 // indirect
golang.org/x/sys v0.12.0 // indirect
golang.org/x/time v0.3.0 // indirect
golang.org/x/tools v0.6.0 // indirect
golang.org/x/tools v0.13.0 // indirect
golang.org/x/xerrors v0.0.0-20220907171357-04be3eba64a2 // indirect
google.golang.org/appengine v1.6.7 // indirect
google.golang.org/genproto v0.0.0-20230410155749-daa745c078e1 // indirect
google.golang.org/grpc v1.54.0 // indirect
google.golang.org/protobuf v1.30.0 // indirect
google.golang.org/genproto v0.0.0-20230803162519-f966b187b2e5 // indirect
google.golang.org/genproto/googleapis/api v0.0.0-20230803162519-f966b187b2e5 // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20230911183012-2d3300fd4832 // indirect
google.golang.org/grpc v1.57.0 // indirect
google.golang.org/protobuf v1.31.0 // indirect
)
Loading

0 comments on commit 279f8d1

Please sign in to comment.