Skip to content

Commit

Permalink
Merge branch 'main' into add_array_functions_to_keywords
Browse files Browse the repository at this point in the history
  • Loading branch information
harshachinta committed May 7, 2024
2 parents 47e6be8 + 3ffbbbe commit a8294bf
Show file tree
Hide file tree
Showing 15 changed files with 1,603 additions and 38 deletions.
4 changes: 2 additions & 2 deletions .release-please-manifest-individual.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@
"firestore": "1.15.0",
"logging": "1.9.0",
"profiler": "0.4.0",
"pubsub": "1.37.0",
"pubsub": "1.38.0",
"pubsublite": "1.8.1",
"spanner": "1.61.0",
"storage": "1.40.0",
"vertexai": "0.7.1"
"vertexai": "0.8.0"
}
18 changes: 16 additions & 2 deletions pubsub/CHANGES.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,21 @@
# Changes

## [1.38.0](https://github.com/googleapis/google-cloud-go/compare/pubsub/v1.37.0...pubsub/v1.38.0) (2024-05-06)


### Features

* **pubsub:** Add custom datetime format for Cloud Storage subscriptions ([4834425](https://github.com/googleapis/google-cloud-go/commit/48344254a5d21ec51ffee275c78a15c9345dc09c))
* **pubsub:** Support publisher compression ([#9711](https://github.com/googleapis/google-cloud-go/issues/9711)) ([4940c3c](https://github.com/googleapis/google-cloud-go/commit/4940c3c5ab31b6e66ec8f29f9cf60298f8de630a))
* **pubsub:** Use Streaming Pull response for ordering check ([#9682](https://github.com/googleapis/google-cloud-go/issues/9682)) ([7bf4904](https://github.com/googleapis/google-cloud-go/commit/7bf49049cdc44ca260d1c1354bc7661de9ed8585))


### Bug Fixes

* **pubsub:** Bump x/net to v0.24.0 ([ba31ed5](https://github.com/googleapis/google-cloud-go/commit/ba31ed5fda2c9664f2e1cf972469295e63deb5b4))
* **pubsub:** Respect gRPC dial option when PUBSUB_EMULATOR_HOST is set ([#10040](https://github.com/googleapis/google-cloud-go/issues/10040)) ([95bf6b2](https://github.com/googleapis/google-cloud-go/commit/95bf6b255d8ff7bb385567da498b90252efb338f))
* **pubsub:** Update protobuf dep to v1.33.0 ([30b038d](https://github.com/googleapis/google-cloud-go/commit/30b038d8cac0b8cd5dd4761c87f3f298760dd33a))

## [1.37.0](https://github.com/googleapis/google-cloud-go/compare/pubsub/v1.36.2...pubsub/v1.37.0) (2024-03-07)


Expand Down Expand Up @@ -577,5 +593,3 @@ Small fix to a package name.

This is the first tag to carve out pubsub as its own module. See:
https://github.com/golang/go/wiki/Modules#is-it-possible-to-add-a-module-to-a-multi-module-repository.


2 changes: 1 addition & 1 deletion pubsub/internal/version.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,4 @@
package internal

// Version is the current tagged release of the library.
const Version = "1.37.0"
const Version = "1.38.0"
13 changes: 8 additions & 5 deletions pubsub/pubsub.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ import (
"cloud.google.com/go/pubsub/internal"
gax "github.com/googleapis/gax-go/v2"
"google.golang.org/api/option"
"google.golang.org/api/option/internaloption"
"google.golang.org/grpc"
"google.golang.org/grpc/keepalive"
)
Expand Down Expand Up @@ -143,12 +144,14 @@ func NewClientWithConfig(ctx context.Context, projectID string, config *ClientCo
// Environment variables for gcloud emulator:
// https://cloud.google.com/sdk/gcloud/reference/beta/emulators/pubsub/
if addr := os.Getenv("PUBSUB_EMULATOR_HOST"); addr != "" {
conn, err := grpc.Dial(addr, grpc.WithInsecure())
if err != nil {
return nil, fmt.Errorf("grpc.Dial: %w", err)
emulatorOpts := []option.ClientOption{
option.WithEndpoint(addr),
option.WithGRPCDialOption(grpc.WithInsecure()),
option.WithoutAuthentication(),
option.WithTelemetryDisabled(),
internaloption.SkipDialSettingsValidation(),
}
o = []option.ClientOption{option.WithGRPCConn(conn)}
o = append(o, option.WithTelemetryDisabled())
opts = append(emulatorOpts, opts...)
} else {
numConns := runtime.GOMAXPROCS(0)
if numConns > 4 {
Expand Down
569 changes: 568 additions & 1 deletion spanner/integration_test.go

Large diffs are not rendered by default.

8 changes: 5 additions & 3 deletions spanner/key.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import (
"cloud.google.com/go/civil"
sppb "cloud.google.com/go/spanner/apiv1/spannerpb"
"google.golang.org/grpc/codes"
"google.golang.org/protobuf/reflect/protoreflect"
proto3 "google.golang.org/protobuf/types/known/structpb"
)

Expand Down Expand Up @@ -58,6 +59,7 @@ import (
// - string and NullString are mapped to Cloud Spanner's STRING type.
// - time.Time and NullTime are mapped to Cloud Spanner's TIMESTAMP type.
// - civil.Date and NullDate are mapped to Cloud Spanner's DATE type.
// - protoreflect.Enum and NullProtoEnum are mapped to Cloud Spanner's ENUM type.
type Key []interface{}

// errInvdKeyPartType returns error for unsupported key part type.
Expand All @@ -83,7 +85,7 @@ func keyPartValue(part interface{}) (pb *proto3.Value, err error) {
pb, _, err = encodeValue(int64(v))
case uint32:
pb, _, err = encodeValue(int64(v))
case int64, float64, float32, NullInt64, NullFloat64, NullFloat32, bool, NullBool, []byte, string, NullString, time.Time, civil.Date, NullTime, NullDate, big.Rat, NullNumeric:
case int64, float64, float32, NullInt64, NullFloat64, NullFloat32, bool, NullBool, []byte, string, NullString, time.Time, civil.Date, NullTime, NullDate, big.Rat, NullNumeric, protoreflect.Enum, NullProtoEnum:
pb, _, err = encodeValue(v)
case Encoder:
part, err = v.EncodeSpanner()
Expand Down Expand Up @@ -138,7 +140,7 @@ func (key Key) String() string {

func (key Key) elemString(b *bytes.Buffer, part interface{}) {
switch v := part.(type) {
case int, int8, int16, int32, int64, uint, uint8, uint16, uint32, float32, float64, bool:
case int, int8, int16, int32, int64, uint, uint8, uint16, uint32, float32, float64, bool, protoreflect.Enum:
// Use %v to print numeric types and bool.
fmt.Fprintf(b, "%v", v)
case string:
Expand All @@ -149,7 +151,7 @@ func (key Key) elemString(b *bytes.Buffer, part interface{}) {
} else {
fmt.Fprint(b, nullString)
}
case NullInt64, NullFloat64, NullBool, NullNumeric:
case NullInt64, NullFloat64, NullBool, NullNumeric, NullProtoEnum:
// The above types implement fmt.Stringer.
fmt.Fprintf(b, "%s", v)
case NullString, NullDate, NullTime:
Expand Down
11 changes: 11 additions & 0 deletions spanner/key_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import (

"cloud.google.com/go/civil"
sppb "cloud.google.com/go/spanner/apiv1/spannerpb"
pb "cloud.google.com/go/spanner/testdata/protos"
proto3 "google.golang.org/protobuf/types/known/structpb"
)

Expand Down Expand Up @@ -244,6 +245,16 @@ func TestKey(t *testing.T) {
wantProto: nil,
wantStr: `(error)`,
},
{
k: Key{pb.Genre_ROCK},
wantProto: listValueProto(stringProto("3")),
wantStr: "(ROCK)",
},
{
k: Key{NullProtoEnum{pb.Genre_FOLK, true}},
wantProto: listValueProto(stringProto("2")),
wantStr: "(FOLK)",
},
} {
if got := test.k.String(); got != test.wantStr {
t.Errorf("%v.String() = %v, want %v", test.k, got, test.wantStr)
Expand Down
19 changes: 19 additions & 0 deletions spanner/protoutils.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ import (

"cloud.google.com/go/civil"
sppb "cloud.google.com/go/spanner/apiv1/spannerpb"
"google.golang.org/protobuf/proto"
"google.golang.org/protobuf/reflect/protoreflect"
proto3 "google.golang.org/protobuf/types/known/structpb"
)

Expand Down Expand Up @@ -144,3 +146,20 @@ func structType(fields ...*sppb.StructType_Field) *sppb.Type {
func nullProto() *proto3.Value {
return &proto3.Value{Kind: &proto3.Value_NullValue{NullValue: proto3.NullValue_NULL_VALUE}}
}

func protoMessageType(fqn string) *sppb.Type {
return &sppb.Type{Code: sppb.TypeCode_PROTO, ProtoTypeFqn: fqn}
}

func protoEnumType(fqn string) *sppb.Type {
return &sppb.Type{Code: sppb.TypeCode_ENUM, ProtoTypeFqn: fqn}
}

func protoMessageProto(m proto.Message) *proto3.Value {
var b, _ = proto.Marshal(m)
return &proto3.Value{Kind: &proto3.Value_StringValue{StringValue: base64.StdEncoding.EncodeToString(b)}}
}

func protoEnumProto(e protoreflect.Enum) *proto3.Value {
return &proto3.Value{Kind: &proto3.Value_StringValue{StringValue: strconv.FormatInt(int64(e.Number()), 10)}}
}
Binary file added spanner/testdata/protos/descriptors.pb
Binary file not shown.
Loading

0 comments on commit a8294bf

Please sign in to comment.