pubsub: accept nil duration from server
Although the service should never give us a nil Subscription.MessageRetentionDuration,
the emulator still does.
Fixes
@@ -169,10 +169,14 @@ func (cfg *SubscriptionConfig) toProto(name string) *pb.Subscription {
}
func protoToSubscriptionConfig(pbSub *pb.Subscription, c *Client) (SubscriptionConfig, error) {
- rd, err := ptypes.Duration(pbSub.MessageRetentionDuration)
+ rd := time.Hour * 24 * 7
+ var err error
+ if pbSub.MessageRetentionDuration != nil {
+ rd, err = ptypes.Duration(pbSub.MessageRetentionDuration)
if err != nil {
return SubscriptionConfig{}, err
}
+ }
return SubscriptionConfig{
Topic: newTopic(c, pbSub.Topic),
AckDeadline: time.Second * time.Duration(pbSub.AckDeadlineSeconds),
