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

Add new Logpush fields for max upload params #1272

Merged
merged 2 commits into from
Apr 23, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .changelog/1272.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release-note:enhancement
logpush: add support for max upload parameters
```
29 changes: 16 additions & 13 deletions logpush.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,19 +11,22 @@ import (

// LogpushJob describes a Logpush job.
type LogpushJob struct {
ID int `json:"id,omitempty"`
Dataset string `json:"dataset"`
Enabled bool `json:"enabled"`
Kind string `json:"kind,omitempty"`
Name string `json:"name"`
LogpullOptions string `json:"logpull_options"`
DestinationConf string `json:"destination_conf"`
OwnershipChallenge string `json:"ownership_challenge,omitempty"`
LastComplete *time.Time `json:"last_complete,omitempty"`
LastError *time.Time `json:"last_error,omitempty"`
ErrorMessage string `json:"error_message,omitempty"`
Frequency string `json:"frequency,omitempty"`
Filter *LogpushJobFilters `json:"filter,omitempty"`
ID int `json:"id,omitempty"`
Dataset string `json:"dataset"`
Enabled bool `json:"enabled"`
Kind string `json:"kind,omitempty"`
Name string `json:"name"`
LogpullOptions string `json:"logpull_options"`
DestinationConf string `json:"destination_conf"`
OwnershipChallenge string `json:"ownership_challenge,omitempty"`
LastComplete *time.Time `json:"last_complete,omitempty"`
LastError *time.Time `json:"last_error,omitempty"`
ErrorMessage string `json:"error_message,omitempty"`
Frequency string `json:"frequency,omitempty"`
Filter *LogpushJobFilters `json:"filter,omitempty"`
MaxUploadBytes int `json:"max_upload_bytes,omitempty"`
MaxUploadRecords int `json:"max_upload_records,omitempty"`
MaxUploadIntervalSeconds int `json:"max_upload_interval_seconds,omitempty"`
}

type LogpushJobFilters struct {
Expand Down
18 changes: 11 additions & 7 deletions logpush_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@ const (
"last_complete": "%[2]s",
"last_error": "%[2]s",
"error_message": "test",
"frequency": "high"
"frequency": "high",
"max_upload_bytes": 5000000
}
`
serverEdgeLogpushJobDescription = `{
Expand Down Expand Up @@ -72,6 +73,7 @@ var (
LastError: &testLogpushTimestamp,
ErrorMessage: "test",
Frequency: "high",
MaxUploadBytes: 5000000,
}
expectedEdgeLogpushJobStruct = LogpushJob{
ID: jobID,
Expand Down Expand Up @@ -177,18 +179,20 @@ func TestCreateLogpushJob(t *testing.T) {
}{
"core logpush job": {
newJob: LogpushJob{
Dataset: "http_requests",
Enabled: false,
Name: "example.com",
LogpullOptions: "fields=RayID,ClientIP,EdgeStartTimestamp&timestamps=rfc3339",
DestinationConf: "s3://mybucket/logs?region=us-west-2",
Dataset: "http_requests",
Enabled: false,
Name: "example.com",
LogpullOptions: "fields=RayID,ClientIP,EdgeStartTimestamp&timestamps=rfc3339",
DestinationConf: "s3://mybucket/logs?region=us-west-2",
MaxUploadRecords: 1000,
},
payload: `{
"dataset": "http_requests",
"enabled":false,
"name":"example.com",
"logpull_options":"fields=RayID,ClientIP,EdgeStartTimestamp&timestamps=rfc3339",
"destination_conf":"s3://mybucket/logs?region=us-west-2"
"destination_conf":"s3://mybucket/logs?region=us-west-2",
"max_upload_records": 1000
}`,
result: serverLogpushJobDescription,
want: expectedLogpushJobStruct,
Expand Down