Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix point in time keep alive handling #1525

Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
22 changes: 15 additions & 7 deletions pit.go
Expand Up @@ -17,20 +17,28 @@ type PointInTime struct {
}

// NewPointInTime creates a new PointInTime.
func NewPointInTime(id, keepAlive string) *PointInTime {
return &PointInTime{
func NewPointInTime(id string, keepAlive ...string) *PointInTime {
pit := &PointInTime{
Id: id,
KeepAlive: keepAlive,
}
if len(keepAlive) > 1 {
pit.KeepAlive = keepAlive[0]
}
return pit
}

// Source generates the JSON serializable fragment for the PointInTime.
func (pit *PointInTime) Source() (interface{}, error) {
if pit == nil {
return nil, nil
}
return map[string]interface{}{
"id": pit.Id,
"keep_alive": pit.KeepAlive,
}, nil
source := map[string]interface{}{
"id": pit.Id,
}

if pit.KeepAlive != "" {
source["keep_alive"] = pit.KeepAlive
}

return source, nil
}