Skip to content

Commit

Permalink
feat: add creation time for stream and subscription
Browse files Browse the repository at this point in the history
  • Loading branch information
YangKian committed Jan 18, 2023
1 parent 6ff4a75 commit 43b741f
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
6 changes: 6 additions & 0 deletions hstream/stream.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@ package hstream

import (
"fmt"
"time"

"google.golang.org/protobuf/types/known/timestamppb"

"github.com/hstreamdb/hstreamdb-go/internal/hstreamrpc"
hstreampb "github.com/hstreamdb/hstreamdb-go/proto/gen-proto/hstreamdb/hstream/server"
Expand All @@ -14,6 +17,7 @@ type Stream struct {
// backlog duration == 0 means forbidden backlog
BacklogDuration uint32
ShardCount uint32
CreationTime time.Time
}

func (s *Stream) StreamToPb() *hstreampb.Stream {
Expand All @@ -22,6 +26,7 @@ func (s *Stream) StreamToPb() *hstreampb.Stream {
ReplicationFactor: s.ReplicationFactor,
BacklogDuration: s.BacklogDuration,
ShardCount: s.ShardCount,
CreationTime: timestamppb.New(s.CreationTime),
}
}

Expand All @@ -31,6 +36,7 @@ func StreamFromPb(pb *hstreampb.Stream) Stream {
ReplicationFactor: pb.ReplicationFactor,
BacklogDuration: pb.BacklogDuration,
ShardCount: pb.ShardCount,
CreationTime: pb.CreationTime.AsTime(),
}
}

Expand Down
6 changes: 6 additions & 0 deletions hstream/subscription.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@ package hstream

import (
"fmt"
"time"

"google.golang.org/protobuf/types/known/timestamppb"

"github.com/hstreamdb/hstreamdb-go/internal/hstreamrpc"
hstreampb "github.com/hstreamdb/hstreamdb-go/proto/gen-proto/hstreamdb/hstream/server"
Expand All @@ -23,6 +26,7 @@ type Subscription struct {
AckTimeoutSeconds int32
MaxUnackedRecords int32
Offset SubscriptionOffset
CreationTime time.Time
}

func (s *Subscription) SubscriptionToPb() *hstreampb.Subscription {
Expand All @@ -32,6 +36,7 @@ func (s *Subscription) SubscriptionToPb() *hstreampb.Subscription {
AckTimeoutSeconds: s.AckTimeoutSeconds,
MaxUnackedRecords: s.MaxUnackedRecords,
Offset: SubscriptionOffsetToPb(s.Offset),
CreationTime: timestamppb.New(s.CreationTime),
}
}

Expand All @@ -42,6 +47,7 @@ func SubscriptionFromPb(pb *hstreampb.Subscription) Subscription {
AckTimeoutSeconds: pb.AckTimeoutSeconds,
MaxUnackedRecords: pb.MaxUnackedRecords,
Offset: SubscriptionOffsetFromPb(pb.Offset),
CreationTime: pb.CreationTime.AsTime(),
}
}

Expand Down

0 comments on commit 43b741f

Please sign in to comment.