From de95e8da590887c67b90209f8a9e919bccda0d37 Mon Sep 17 00:00:00 2001 From: mclcavalcante Date: Mon, 7 Mar 2022 19:31:46 -0300 Subject: [PATCH] feat(dataset): rename DeleteSinkFromAllDatasets to DeleteSinkFromAllDatasetsInternal method and InactivateDatasetById to InactivateDatasetByIdInternal method --- policies/api/http/logging.go | 8 ++++---- policies/api/http/metrics.go | 8 ++++---- policies/policies.go | 8 ++++---- policies/policy_service.go | 4 ++-- policies/policy_service_test.go | 4 ++-- policies/redis/consumer/streams.go | 4 ++-- policies/redis/producer/streams.go | 8 ++++---- 7 files changed, 22 insertions(+), 22 deletions(-) diff --git a/policies/api/http/logging.go b/policies/api/http/logging.go index 2869f83ff..3a331f8fa 100644 --- a/policies/api/http/logging.go +++ b/policies/api/http/logging.go @@ -18,7 +18,7 @@ type loggingMiddleware struct { svc policies.Service } -func (l loggingMiddleware) InactivateDatasetByID(ctx context.Context, datasetID string, ownerID string) (err error) { +func (l loggingMiddleware) InactivateDatasetByIDInternal(ctx context.Context, datasetID string, ownerID string) (err error) { defer func(begin time.Time) { if err != nil { l.logger.Warn("method call: inactivate_dataset_by_id", @@ -29,7 +29,7 @@ func (l loggingMiddleware) InactivateDatasetByID(ctx context.Context, datasetID zap.Duration("duration", time.Since(begin))) } }(time.Now()) - return l.svc.InactivateDatasetByID(ctx, datasetID, ownerID) + return l.svc.InactivateDatasetByIDInternal(ctx, datasetID, ownerID) } func (l loggingMiddleware) ViewDatasetByIDInternal(ctx context.Context, ownerID string, datasetID string) (_ policies.Dataset, err error) { @@ -270,7 +270,7 @@ func (l loggingMiddleware) ListDatasets(ctx context.Context, token string, pm po return l.svc.ListDatasets(ctx, token, pm) } -func (l loggingMiddleware) DeleteSinkFromAllDatasets(ctx context.Context, sinkID string, ownerID string) (ds []policies.Dataset, err error) { +func (l loggingMiddleware) DeleteSinkFromAllDatasetsInternal(ctx context.Context, sinkID string, ownerID string) (ds []policies.Dataset, err error) { defer func(begin time.Time) { if err != nil { l.logger.Warn("method call: delete_sink_from_all_datasets", @@ -281,7 +281,7 @@ func (l loggingMiddleware) DeleteSinkFromAllDatasets(ctx context.Context, sinkID zap.Duration("duration", time.Since(begin))) } }(time.Now()) - return l.svc.DeleteSinkFromAllDatasets(ctx, sinkID, ownerID) + return l.svc.DeleteSinkFromAllDatasetsInternal(ctx, sinkID, ownerID) } func NewLoggingMiddleware(svc policies.Service, logger *zap.Logger) policies.Service { diff --git a/policies/api/http/metrics.go b/policies/api/http/metrics.go index ab6ce1742..7d4db165c 100644 --- a/policies/api/http/metrics.go +++ b/policies/api/http/metrics.go @@ -22,7 +22,7 @@ type metricsMiddleware struct { svc policies.Service } -func (m metricsMiddleware) InactivateDatasetByID(ctx context.Context, datasetID string, ownerID string) error { +func (m metricsMiddleware) InactivateDatasetByIDInternal(ctx context.Context, datasetID string, ownerID string) error { defer func(begin time.Time) { labels := []string{ "method", "inactivateDatasetByID", @@ -36,7 +36,7 @@ func (m metricsMiddleware) InactivateDatasetByID(ctx context.Context, datasetID }(time.Now()) - return m.svc.InactivateDatasetByID(ctx, datasetID, ownerID) + return m.svc.InactivateDatasetByIDInternal(ctx, datasetID, ownerID) } func (m metricsMiddleware) ViewDatasetByIDInternal(ctx context.Context, ownerID string, datasetID string) (policies.Dataset, error) { @@ -393,7 +393,7 @@ func (m metricsMiddleware) ListDatasets(ctx context.Context, token string, pm po return m.svc.ListDatasets(ctx, token, pm) } -func (m metricsMiddleware) DeleteSinkFromAllDatasets(ctx context.Context, sinkID string, ownerID string) ([]policies.Dataset, error) { +func (m metricsMiddleware) DeleteSinkFromAllDatasetsInternal(ctx context.Context, sinkID string, ownerID string) ([]policies.Dataset, error) { defer func(begin time.Time) { labels := []string{ "method", "deleteSinkFromAllDatasets", @@ -407,7 +407,7 @@ func (m metricsMiddleware) DeleteSinkFromAllDatasets(ctx context.Context, sinkID }(time.Now()) - return m.svc.DeleteSinkFromAllDatasets(ctx, sinkID, ownerID) + return m.svc.DeleteSinkFromAllDatasetsInternal(ctx, sinkID, ownerID) } func (m metricsMiddleware) identify(token string) (string, error) { diff --git a/policies/policies.go b/policies/policies.go index db765640b..4778babbf 100644 --- a/policies/policies.go +++ b/policies/policies.go @@ -103,11 +103,11 @@ type Service interface { // ListDatasets retrieve a list of Dataset by owner ListDatasets(ctx context.Context, token string, pm PageMetadata) (PageDataset, error) - // InactivateDatasetByID inactivate a dataset - InactivateDatasetByID(ctx context.Context, datasetID string, ownerID string) error + // InactivateDatasetByIDInternal inactivate a dataset + InactivateDatasetByIDInternal(ctx context.Context, datasetID string, ownerID string) error - // DeleteSinkFromAllDatasets removes a sink from a dataset - DeleteSinkFromAllDatasets(ctx context.Context, sinkID string, ownerID string) ([]Dataset, error) + // DeleteSinkFromAllDatasetsInternal removes a sink from a dataset + DeleteSinkFromAllDatasetsInternal(ctx context.Context, sinkID string, ownerID string) ([]Dataset, error) } type Repository interface { diff --git a/policies/policy_service.go b/policies/policy_service.go index 737ac303c..c90112dd1 100644 --- a/policies/policy_service.go +++ b/policies/policy_service.go @@ -329,7 +329,7 @@ func (s policiesService) ListDatasets(ctx context.Context, token string, pm Page return s.repo.RetrieveAllDatasetsByOwner(ctx, ownerID, pm) } -func (s policiesService) DeleteSinkFromAllDatasets(ctx context.Context, sinkID string, ownerID string) ([]Dataset, error) { +func (s policiesService) DeleteSinkFromAllDatasetsInternal(ctx context.Context, sinkID string, ownerID string) ([]Dataset, error) { if sinkID == "" || ownerID == ""{ return []Dataset{}, ErrMalformedEntity } @@ -342,7 +342,7 @@ func (s policiesService) DeleteSinkFromAllDatasets(ctx context.Context, sinkID s return datasets, nil } -func (s policiesService) InactivateDatasetByID(ctx context.Context, datasetID string, ownerID string) error { +func (s policiesService) InactivateDatasetByIDInternal(ctx context.Context, datasetID string, ownerID string) error { if datasetID == "" || ownerID == ""{ return ErrMalformedEntity } diff --git a/policies/policy_service_test.go b/policies/policy_service_test.go index 752432fac..17585fcfe 100644 --- a/policies/policy_service_test.go +++ b/policies/policy_service_test.go @@ -1170,7 +1170,7 @@ func TestDeleteSinkFromDataset(t *testing.T) { for desc, tc := range cases { t.Run(desc, func(t *testing.T) { - _, err := svc.DeleteSinkFromAllDatasets(context.Background(), tc.sinkID, tc.ownerID) + _, err := svc.DeleteSinkFromAllDatasetsInternal(context.Background(), tc.sinkID, tc.ownerID) assert.True(t, errors.Contains(err, tc.err), fmt.Sprintf("%s: expected %s got %s", desc, tc.err, err)) }) } @@ -1247,7 +1247,7 @@ func TestInactivateDatasetByID(t *testing.T) { for desc, tc := range cases { t.Run(desc, func(t *testing.T) { for _, id := range tc.datasetIDs { - err := svc.InactivateDatasetByID(context.Background(), id, tc.ownerID) + err := svc.InactivateDatasetByIDInternal(context.Background(), id, tc.ownerID) assert.True(t, errors.Contains(err, tc.err), fmt.Sprintf("%s: expected %s got %s", desc, tc.err, err)) } }) diff --git a/policies/redis/consumer/streams.go b/policies/redis/consumer/streams.go index 0f70853f7..0d03389d5 100644 --- a/policies/redis/consumer/streams.go +++ b/policies/redis/consumer/streams.go @@ -147,14 +147,14 @@ func (es eventStore) handleAgentGroupRemove(ctx context.Context, groupID string, func (es eventStore) handleSinkRemove(ctx context.Context, sinkID string, ownerID string) error { - datasets, err := es.policiesService.DeleteSinkFromAllDatasets(ctx, sinkID, ownerID) + datasets, err := es.policiesService.DeleteSinkFromAllDatasetsInternal(ctx, sinkID, ownerID) if err != nil { return err } for _, ds := range datasets { if len(ds.SinkIDs) == 0 { - err = es.policiesService.InactivateDatasetByID(ctx, ds.ID, ownerID) + err = es.policiesService.InactivateDatasetByIDInternal(ctx, ds.ID, ownerID) if err != nil { return err } diff --git a/policies/redis/producer/streams.go b/policies/redis/producer/streams.go index cf63df6d1..99e2c2218 100644 --- a/policies/redis/producer/streams.go +++ b/policies/redis/producer/streams.go @@ -229,17 +229,17 @@ func (e eventStore) ValidatePolicy(ctx context.Context, token string, p policies return e.svc.ValidatePolicy(ctx, token, p, format, policyData) } -func (e eventStore) DeleteSinkFromAllDatasets(ctx context.Context, sinkID string, token string) ([]policies.Dataset, error) { - return e.svc.DeleteSinkFromAllDatasets(ctx, sinkID, token) +func (e eventStore) DeleteSinkFromAllDatasetsInternal(ctx context.Context, sinkID string, token string) ([]policies.Dataset, error) { + return e.svc.DeleteSinkFromAllDatasetsInternal(ctx, sinkID, token) } -func (e eventStore) InactivateDatasetByID(ctx context.Context, datasetID string, ownerID string) error { +func (e eventStore) InactivateDatasetByIDInternal(ctx context.Context, datasetID string, ownerID string) error { ds, err := e.svc.ViewDatasetByIDInternal(ctx, ownerID, datasetID) if err != nil { return err } - if err := e.svc.InactivateDatasetByID(ctx, datasetID, ownerID); err != nil { + if err := e.svc.InactivateDatasetByIDInternal(ctx, datasetID, ownerID); err != nil { return err }