Skip to content

Commit

Permalink
add comment
Browse files Browse the repository at this point in the history
Signed-off-by: myan <[email protected]>
  • Loading branch information
yanmxa committed Jul 5, 2024
1 parent f60131c commit 1d61c8c
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
1 change: 1 addition & 0 deletions pkg/dao/resource.go
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,7 @@ func (d *sqlResourceDao) All(ctx context.Context) (api.ResourceList, error) {
return resources, nil
}

// FirstByConsumerName will take the first item of the resources, a common scenario is using it to determine whether the result exists in the table.
func (d *sqlResourceDao) FirstByConsumerName(ctx context.Context, consumerName string) (api.Resource, error) {
g2 := (*d.sessionFactory).New(ctx)
resource := api.Resource{}
Expand Down
5 changes: 5 additions & 0 deletions pkg/services/consumer.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,11 @@ func (s *sqlConsumerService) Replace(ctx context.Context, consumer *api.Consumer
return consumer, nil
}

// Delete will remove the consumer from the storage. Currently, it will:
// 1. Perform a soft delete on the consumer, the resources can be attached to it even after the operation.
// 2. Forbid consumer deletion if there are associated resources.
// 3. Allow the consumer deletion with resources marked as deleted.
// TODO: Additional deletion options or strategies may be added in the future.
func (s *sqlConsumerService) Delete(ctx context.Context, id string) *errors.ServiceError {
consumer, err := s.Get(ctx, id)
if err != nil {
Expand Down

0 comments on commit 1d61c8c

Please sign in to comment.