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

Drop the trim response #308

Merged
merged 2 commits into from
May 29, 2024
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
22 changes: 5 additions & 17 deletions axiom/datasets.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,17 +82,6 @@ type Dataset struct {
CreatedAt time.Time `json:"created"`
}

// TrimResult is the result of a trim operation.
//
// Deprecated: TrimResult is deprecated and will be removed in a future release.
type TrimResult struct {
// BlocksDeleted is the amount of blocks deleted by the trim operation.
//
// Deprecated: BlocksDeleted is deprecated and will be removed in the
// future.
BlocksDeleted int `json:"numDeleted"`
}

// DatasetCreateRequest is a request used to create a dataset.
type DatasetCreateRequest struct {
// Name of the dataset to create. Restricted to 80 characters of [a-zA-Z0-9]
Expand Down Expand Up @@ -276,7 +265,7 @@ func (s *DatasetsService) Delete(ctx context.Context, id string) error {
// Trim the dataset identified by its id to a given length. The max duration
// given will mark the oldest timestamp an event can have. Older ones will be
// deleted from the dataset.
func (s *DatasetsService) Trim(ctx context.Context, id string, maxDuration time.Duration) (*TrimResult, error) {
func (s *DatasetsService) Trim(ctx context.Context, id string, maxDuration time.Duration) error {
ctx, span := s.client.trace(ctx, "Datasets.Trim", trace.WithAttributes(
attribute.String("axiom.dataset_id", id),
attribute.String("axiom.param.max_duration", maxDuration.String()),
Expand All @@ -289,15 +278,14 @@ func (s *DatasetsService) Trim(ctx context.Context, id string, maxDuration time.

path, err := url.JoinPath(s.basePath, id, "trim")
if err != nil {
return nil, spanError(span, err)
return spanError(span, err)
}

var res TrimResult
if err := s.client.Call(ctx, http.MethodPost, path, req, &res); err != nil {
return nil, spanError(span, err)
if err := s.client.Call(ctx, http.MethodPost, path, req, nil); err != nil {
return spanError(span, err)
}

return &res, nil
return nil
}

// Ingest data into the dataset identified by its id.
Expand Down
6 changes: 1 addition & 5 deletions axiom/datasets_integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -322,12 +322,8 @@ func (s *DatasetsTestSuite) Test() {
}

// Trim the dataset down to a minimum.
trimResult, err := s.client.Datasets.Trim(s.ctx, s.dataset.ID, time.Second)
err = s.client.Datasets.Trim(s.ctx, s.dataset.ID, time.Second)
s.Require().NoError(err)
s.Require().NotNil(trimResult)

// HINT(lukasmalkmus): There are no blocks to trim in this test.
s.EqualValues(0, trimResult.BlocksDeleted)
}

func (s *DatasetsTestSuite) TestCursor() {
Expand Down
14 changes: 1 addition & 13 deletions axiom/datasets_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -388,26 +388,14 @@ func TestDatasetsService_Delete(t *testing.T) {
}

func TestDatasetsService_Trim(t *testing.T) {
exp := &TrimResult{
BlocksDeleted: 0,
}

hf := func(w http.ResponseWriter, r *http.Request) {
assert.Equal(t, http.MethodPost, r.Method)

w.Header().Set("Content-Type", mediaTypeJSON)
_, err := fmt.Fprint(w, `{
"numDeleted": 0
}`)
assert.NoError(t, err)
}

client := setup(t, "/v2/datasets/test/trim", hf)

res, err := client.Datasets.Trim(context.Background(), "test", time.Hour)
err := client.Datasets.Trim(context.Background(), "test", time.Hour)
require.NoError(t, err)

assert.Equal(t, exp, res)
}

// TestDatasetsService_Ingest tests the ingest functionality of the client. It
Expand Down
Loading