Skip to content

Commit

Permalink
Merge pull request #4 from cloudspannerecosystem/fgac
Browse files Browse the repository at this point in the history
Support Fine-Grained Access Control (with small API change)
  • Loading branch information
yfuruyama authored Mar 13, 2023
2 parents 01119f7 + 6fd617f commit a8ae954
Show file tree
Hide file tree
Showing 5 changed files with 869 additions and 61 deletions.
22 changes: 12 additions & 10 deletions changestreams/reader.go
Original file line number Diff line number Diff line change
Expand Up @@ -125,23 +125,25 @@ type Config struct {
// If StartTimestamp is a zero value of time.Time, reader reads from the current timestamp.
StartTimestamp time.Time
// If EndTimestamp is a zero value of time.Time, reader reads until it is cancelled.
EndTimestamp time.Time
HeartbeatInterval time.Duration
EndTimestamp time.Time
HeartbeatInterval time.Duration
SpannerClientConfig spanner.ClientConfig
SpannerClientOptions []option.ClientOption
}

// NewReader creates a new reader.
func NewReader(ctx context.Context, projectID, instanceID, databaseID, streamID string, opts ...option.ClientOption) (*Reader, error) {
return NewReaderWithConfig(ctx, projectID, instanceID, databaseID, streamID, &Config{}, opts...)
func NewReader(ctx context.Context, projectID, instanceID, databaseID, streamID string) (*Reader, error) {
return NewReaderWithConfig(ctx, projectID, instanceID, databaseID, streamID, Config{
SpannerClientConfig: spanner.ClientConfig{
SessionPoolConfig: spanner.DefaultSessionPoolConfig,
},
})
}

// NewReaderWithConfig creates a new reader with a given configuration.
func NewReaderWithConfig(ctx context.Context, projectID, instanceID, databaseID, streamID string, config *Config, opts ...option.ClientOption) (*Reader, error) {
func NewReaderWithConfig(ctx context.Context, projectID, instanceID, databaseID, streamID string, config Config) (*Reader, error) {
dbPath := fmt.Sprintf("projects/%s/instances/%s/databases/%s", projectID, instanceID, databaseID)
client, err := spanner.NewClientWithConfig(ctx, dbPath, spanner.ClientConfig{
SessionPoolConfig: spanner.SessionPoolConfig{
WriteSessions: 0,
},
}, opts...)
client, err := spanner.NewClientWithConfig(ctx, dbPath, config.SpannerClientConfig, config.SpannerClientOptions...)
if err != nil {
return nil, err
}
Expand Down
46 changes: 31 additions & 15 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,22 +1,38 @@
module github.com/cloudspannerecosystem/spanner-change-streams-tail

go 1.16
go 1.17

require (
cloud.google.com/go v0.101.1 // indirect
cloud.google.com/go/spanner v1.32.0
github.com/cespare/xxhash/v2 v2.1.2 // indirect
cloud.google.com/go/spanner v1.44.0
github.com/google/go-cmp v0.5.9
golang.org/x/sync v0.1.0
google.golang.org/api v0.112.0
google.golang.org/genproto v0.0.0-20230306155012-7f2fa6fef1f4
)

require (
cloud.google.com/go v0.110.0 // indirect
cloud.google.com/go/compute v1.18.0 // indirect
cloud.google.com/go/compute/metadata v0.2.3 // indirect
cloud.google.com/go/iam v0.12.0 // indirect
cloud.google.com/go/longrunning v0.4.1 // indirect
github.com/census-instrumentation/opencensus-proto v0.4.1 // indirect
github.com/cespare/xxhash/v2 v2.2.0 // indirect
github.com/cncf/udpa/go v0.0.0-20220112060539-c52dc94e7fbe // indirect
github.com/cncf/xds/go v0.0.0-20220520190051-1e77728a1eaa // indirect
github.com/envoyproxy/protoc-gen-validate v0.6.7 // indirect
github.com/cncf/xds/go v0.0.0-20230310173818-32f1caf87195 // indirect
github.com/envoyproxy/go-control-plane v0.11.0 // indirect
github.com/envoyproxy/protoc-gen-validate v0.9.1 // indirect
github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect
github.com/google/go-cmp v0.5.9
github.com/googleapis/gax-go/v2 v2.4.0 // indirect
golang.org/x/net v0.0.0-20220520000938-2e3eb7b945c2 // indirect
golang.org/x/sync v0.0.0-20220513210516-0976fa681c29
golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a // indirect
golang.org/x/xerrors v0.0.0-20220517211312-f3a8303e98df // indirect
google.golang.org/api v0.80.0
google.golang.org/genproto v0.0.0-20220519153652-3a47de7e79bd
google.golang.org/grpc v1.46.2 // indirect
github.com/golang/protobuf v1.5.3 // indirect
github.com/googleapis/enterprise-certificate-proxy v0.2.3 // indirect
github.com/googleapis/gax-go/v2 v2.7.1 // indirect
go.opencensus.io v0.24.0 // indirect
golang.org/x/net v0.8.0 // indirect
golang.org/x/oauth2 v0.6.0 // indirect
golang.org/x/sys v0.6.0 // indirect
golang.org/x/text v0.8.0 // indirect
golang.org/x/xerrors v0.0.0-20220907171357-04be3eba64a2 // indirect
google.golang.org/appengine v1.6.7 // indirect
google.golang.org/grpc v1.53.0 // indirect
google.golang.org/protobuf v1.29.0 // indirect
)
Loading

0 comments on commit a8ae954

Please sign in to comment.