Skip to content

Commit

Permalink
Merge branch 'main' into civil/add-weekday-add-months-methods
Browse files Browse the repository at this point in the history
  • Loading branch information
quartzmo authored Jan 2, 2025
2 parents 48ece46 + e2796a8 commit 1c79a23
Show file tree
Hide file tree
Showing 13 changed files with 403 additions and 98 deletions.
2 changes: 1 addition & 1 deletion .release-please-manifest-individual.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"datastore": "1.20.0",
"errorreporting": "0.3.2",
"firestore": "1.17.0",
"logging": "1.12.0",
"logging": "1.13.0",
"profiler": "0.4.2",
"pubsub": "1.45.3",
"pubsublite": "1.8.2",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"clientLibrary": {
"name": "cloud.google.com/go/storage/control/apiv2",
"version": "1.48.0",
"version": "1.49.0",
"language": "GO",
"apis": [
{
Expand Down
4 changes: 2 additions & 2 deletions internal/uid/uid.go
Original file line number Diff line number Diff line change
Expand Up @@ -131,11 +131,11 @@ func (s *Space) Timestamp(uid string) (time.Time, bool) {
y, err1 := strconv.Atoi(subs[1])
m, err2 := strconv.Atoi(subs[2])
d, err3 := strconv.Atoi(subs[3])
ns, err4 := strconv.Atoi(subs[4])
ns, err4 := strconv.ParseInt(subs[4], 10, 64)
if err1 != nil || err2 != nil || err3 != nil || err4 != nil {
return time.Time{}, false
}
return time.Date(y, time.Month(m), d, 0, 0, 0, ns, time.UTC), true
return time.Date(y, time.Month(m), d, 0, 0, 0, 0, time.UTC).Add(time.Duration(ns)), true
}

// Older reports whether uid was created by m and has a timestamp older than
Expand Down
15 changes: 14 additions & 1 deletion logging/CHANGES.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,19 @@
# Changes

## [1.13.0](https://github.com/googleapis/google-cloud-go/compare/logging/v1.12.0...logging/v1.13.0) (2025-01-02)


### Features

* **logging:** Change go gapic transport to grpc+rest in logging ([#11289](https://github.com/googleapis/google-cloud-go/issues/11289)) ([a5f250b](https://github.com/googleapis/google-cloud-go/commit/a5f250baf8085bdb07807869a7c4a3a0ca3f535d))


### Bug Fixes

* **logging:** Update golang.org/x/net to v0.33.0 ([e9b0b69](https://github.com/googleapis/google-cloud-go/commit/e9b0b69644ea5b276cacff0a707e8a5e87efafc9))
* **logging:** Update google.golang.org/api to v0.203.0 ([8bb87d5](https://github.com/googleapis/google-cloud-go/commit/8bb87d56af1cba736e0fe243979723e747e5e11e))
* **logging:** WARNING: On approximately Dec 1, 2024, an update to Protobuf will change service registration function signatures to use an interface instead of a concrete type in generated .pb.go files. This change is expected to affect very few if any users of this client library. For more information, see https://togithub.com/googleapis/google-cloud-go/issues/11020. ([8bb87d5](https://github.com/googleapis/google-cloud-go/commit/8bb87d56af1cba736e0fe243979723e747e5e11e))

## [1.12.0](https://github.com/googleapis/google-cloud-go/compare/logging/v1.11.0...logging/v1.12.0) (2024-10-16)


Expand Down Expand Up @@ -202,4 +216,3 @@

This is the first tag to carve out logging 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 logging/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.12.0"
const Version = "1.13.0"
6 changes: 3 additions & 3 deletions parallelstore/apiv1beta/parallelstorepb/parallelstore.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

60 changes: 29 additions & 31 deletions spanner/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -107,20 +107,19 @@ func parseDatabaseName(db string) (project, instance, database string, err error
// Client is a client for reading and writing data to a Cloud Spanner database.
// A client is safe to use concurrently, except for its Close method.
type Client struct {
sc *sessionClient
idleSessions *sessionPool
logger *log.Logger
qo QueryOptions
ro ReadOptions
ao []ApplyOption
txo TransactionOptions
bwo BatchWriteOptions
ct *commonTags
disableRouteToLeader bool
enableMultiplexedSessionForRW bool
dro *sppb.DirectedReadOptions
otConfig *openTelemetryConfig
metricsTracerFactory *builtinMetricsTracerFactory
sc *sessionClient
idleSessions *sessionPool
logger *log.Logger
qo QueryOptions
ro ReadOptions
ao []ApplyOption
txo TransactionOptions
bwo BatchWriteOptions
ct *commonTags
disableRouteToLeader bool
dro *sppb.DirectedReadOptions
otConfig *openTelemetryConfig
metricsTracerFactory *builtinMetricsTracerFactory
}

// DatabaseName returns the full name of a database, e.g.,
Expand Down Expand Up @@ -548,20 +547,19 @@ func newClientWithConfig(ctx context.Context, database string, config ClientConf
}

c = &Client{
sc: sc,
idleSessions: sp,
logger: config.Logger,
qo: getQueryOptions(config.QueryOptions),
ro: config.ReadOptions,
ao: config.ApplyOptions,
txo: config.TransactionOptions,
bwo: config.BatchWriteOptions,
ct: getCommonTags(sc),
disableRouteToLeader: config.DisableRouteToLeader,
dro: config.DirectedReadOptions,
otConfig: otConfig,
metricsTracerFactory: metricsTracerFactory,
enableMultiplexedSessionForRW: config.enableMultiplexedSessionForRW,
sc: sc,
idleSessions: sp,
logger: config.Logger,
qo: getQueryOptions(config.QueryOptions),
ro: config.ReadOptions,
ao: config.ApplyOptions,
txo: config.TransactionOptions,
bwo: config.BatchWriteOptions,
ct: getCommonTags(sc),
disableRouteToLeader: config.DisableRouteToLeader,
dro: config.DirectedReadOptions,
otConfig: otConfig,
metricsTracerFactory: metricsTracerFactory,
}
return c, nil
}
Expand Down Expand Up @@ -1025,7 +1023,7 @@ func (c *Client) rwTransaction(ctx context.Context, f func(context.Context, *Rea
err error
)
if sh == nil || sh.getID() == "" || sh.getClient() == nil {
if c.enableMultiplexedSessionForRW {
if c.idleSessions.isMultiplexedSessionForRWEnabled() {
sh, err = c.idleSessions.takeMultiplexed(ctx)
} else {
// Session handle hasn't been allocated or has been destroyed.
Expand All @@ -1044,7 +1042,7 @@ func (c *Client) rwTransaction(ctx context.Context, f func(context.Context, *Rea
// Note that the t.begin(ctx) call could change the session that is being used by the transaction, as the
// BeginTransaction RPC invocation will be retried on a new session if it returns SessionNotFound.
t.txReadOnly.sh = sh
if err = t.begin(ctx); err != nil {
if err = t.begin(ctx, nil); err != nil {
trace.TracePrintf(ctx, nil, "Error while BeginTransaction during retrying a ReadWrite transaction: %v", ToSpannerError(err))
return ToSpannerError(err)
}
Expand Down Expand Up @@ -1072,7 +1070,7 @@ func (c *Client) rwTransaction(ctx context.Context, f func(context.Context, *Rea
return err
})
if isUnimplementedErrorForMultiplexedRW(err) {
c.enableMultiplexedSessionForRW = false
c.idleSessions.disableMultiplexedSessionForRW()
}
return resp, err
}
Expand Down
3 changes: 3 additions & 0 deletions spanner/internal/testutil/inmem_spanner_server.go
Original file line number Diff line number Diff line change
Expand Up @@ -1078,6 +1078,9 @@ func (s *inMemSpannerServer) BeginTransaction(ctx context.Context, req *spannerp
}
s.updateSessionLastUseTime(session.Name)
tx := s.beginTransaction(session, req.Options)
if session.Multiplexed && req.MutationKey != nil {
tx.PrecommitToken = s.getPreCommitToken(string(tx.Id), "TransactionPrecommitToken")
}
return tx, nil
}

Expand Down
36 changes: 32 additions & 4 deletions spanner/mutation.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,9 @@ limitations under the License.
package spanner

import (
"math/rand"
"reflect"
"time"

sppb "cloud.google.com/go/spanner/apiv1/spannerpb"
"google.golang.org/grpc/codes"
Expand Down Expand Up @@ -427,24 +429,50 @@ func (m Mutation) proto() (*sppb.Mutation, error) {

// mutationsProto turns a spanner.Mutation array into a sppb.Mutation array,
// it is convenient for sending batch mutations to Cloud Spanner.
func mutationsProto(ms []*Mutation) ([]*sppb.Mutation, error) {
func mutationsProto(ms []*Mutation) ([]*sppb.Mutation, *sppb.Mutation, error) {
var selectedMutation *Mutation
var nonInsertMutations []*Mutation

l := make([]*sppb.Mutation, 0, len(ms))
for _, m := range ms {
if m.op != opInsert {
nonInsertMutations = append(nonInsertMutations, m)
}
if selectedMutation == nil {
selectedMutation = m
}
// Track the INSERT mutation with the highest number of values if only INSERT mutation were found
if selectedMutation.op == opInsert && m.op == opInsert && len(m.values) > len(selectedMutation.values) {
selectedMutation = m
}

// Convert the mutation to sppb.Mutation and add to the list
pb, err := m.proto()
if err != nil {
return nil, err
return nil, nil, err
}
l = append(l, pb)
}
return l, nil
if len(nonInsertMutations) > 0 {
selectedMutation = nonInsertMutations[rand.New(rand.NewSource(time.Now().UnixNano())).Intn(len(nonInsertMutations))]
}
if selectedMutation != nil {
m, err := selectedMutation.proto()
if err != nil {
return nil, nil, err
}
return l, m, nil
}

return l, nil, nil
}

// mutationGroupsProto turns a spanner.MutationGroup array into a
// sppb.BatchWriteRequest_MutationGroup array, in preparation to send RPCs.
func mutationGroupsProto(mgs []*MutationGroup) ([]*sppb.BatchWriteRequest_MutationGroup, error) {
gs := make([]*sppb.BatchWriteRequest_MutationGroup, 0, len(mgs))
for _, mg := range mgs {
ms, err := mutationsProto(mg.Mutations)
ms, _, err := mutationsProto(mg.Mutations)
if err != nil {
return nil, err
}
Expand Down
Loading

0 comments on commit 1c79a23

Please sign in to comment.