breaking changes to spanner client

22 views
Skip to first unread message

Jonathan Amsterdam

unread,
May 26, 2017, 4:47:28 PM5/26/17
to google-api-...@googlegroups.com
1. The function passed to Client.ReadWriteTransaction now takes a context.Context as its first argument.

Instead of 

    c.ReadWriteTransaction(ctx, func(txn *spanner.ReadWriteTransaction) error {...})
    
write

    c.ReadWriteTransaction(ctx, func(ctx context.Context, txn *spanner.ReadWriteTransaction) error {...})

The two contexts (the one you pass to ReadWriteTransaction, and the one we pass back to your function) are not the same.

2. We've revamped KeySets to make them easier to use. Now both Key and KeyRange act as KeySets, so instead of writing

    spanner.Keys(spanner.Key{1})

where a KeySet is required, you can just write

    spanner.Key{1}

and instead of

    spanner.Range(KeyRange{...})

you can just write

    KeyRange{...}

In fact, we removed the Keys and Range functions.

To construct more complicated KeySets, use the spanner.KeySets function (previously named UnionKeySets).

As part of this change, the Delete function takes a KeySet instead of a Key, and since that renders DeleteKeyRange obsolete, we removed it.


Reply all
Reply to author
Forward
0 new messages