-
Notifications
You must be signed in to change notification settings - Fork 214
/
EntityPersistenceOperations.java
55 lines (46 loc) · 1.56 KB
/
EntityPersistenceOperations.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
/*
* Copyright (c) 2017 Contributors to the Eclipse Foundation
*
* See the NOTICE file(s) distributed with this work for additional
* information regarding copyright ownership.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License 2.0 which is available at
* http://www.eclipse.org/legal/epl-2.0
*
* SPDX-License-Identifier: EPL-2.0
*/
package org.eclipse.ditto.internal.utils.persistence.operations;
import java.util.Collection;
import java.util.List;
import org.eclipse.ditto.base.model.entity.id.EntityId;
import org.apache.pekko.NotUsed;
import org.apache.pekko.stream.javadsl.Source;
/**
* Persistence ops on entities.
* <p>
* Currently the only supported operation is 'purge'.
* </p>
*/
public interface EntityPersistenceOperations {
/**
* Purge an entity by the given {@code entityId}.
*
* @param entityId the ID of the entity to delete.
* @return source of any errors during the purge.
*/
Source<List<Throwable>, NotUsed> purgeEntity(EntityId entityId);
/**
* Purge all entities contained in the given {@code entityIds}.
*
* @param entityIds the IDs of the entities to delete
* @return source of any errors during the purge.
*/
default Source<List<Throwable>, NotUsed> purgeEntities(final Collection<EntityId> entityIds) {
Source<List<Throwable>, NotUsed> result = Source.empty();
for (final EntityId entityId : entityIds) {
result = result.merge(purgeEntity(entityId));
}
return result;
}
}