Skip to content

Commit 9c6613c

Browse files
committed
drop: removed old implementation code
1 parent c3ab328 commit 9c6613c

12 files changed

Lines changed: 75 additions & 359 deletions

File tree

.devcontainer/devcontainer.json

Lines changed: 0 additions & 16 deletions
This file was deleted.
Lines changed: 75 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -1,67 +1,105 @@
11
package studio.o7.octopus.plugin.api;
22

3-
import org.jspecify.annotations.NullMarked;
3+
import gentle.Error;
4+
import gentle.Result;
45
import studio.o7.octopus.plugin.Unsafe;
5-
import studio.o7.octopus.plugin.api.listener.Listener;
6-
import studio.o7.octopus.sdk.gen.api.v1.Entry;
7-
import studio.o7.octopus.sdk.gen.api.v1.Object;
6+
import studio.o7.octopus.sdk.v1.Entry;
7+
import studio.o7.octopus.sdk.v1.QueryResponse;
88

9-
import javax.annotation.Nullable;
10-
import java.time.Instant;
11-
import java.util.Collection;
129
import java.util.UUID;
1310

14-
@NullMarked
1511
public interface Octopus {
1612

17-
static Octopus get() {
13+
static Octopus instance() {
1814
return Unsafe.getInstance().get();
1915
}
2016

2117
/**
22-
* Retrieves existing entries from the database matching a
23-
* key pattern.
18+
* Gets a unique entry of the given key
19+
*
20+
* @param key exact key pattern that will match between entries until one is found
21+
* @return Returns the first {@link studio.o7.octopus.sdk.v1.Entry} that matches the key
2422
*/
25-
default Collection<Entry> get(String keyPattern) {
26-
return get(keyPattern, false);
27-
}
28-
29-
/**
30-
* Retrieves existing entries from the database matching a
31-
* key pattern. Can optionally include expired objects.
32-
*/
33-
default Collection<Entry> get(String keyPattern, boolean includeExpired) {
34-
return get(keyPattern, includeExpired, null, null);
35-
}
23+
Result<studio.o7.octopus.sdk.v1.Object, Error> get(String key);
3624

3725
/**
38-
* Retrieves existing entries from the database matching a
39-
* key pattern. Can optionally include expired objects and
40-
* filter by revision creation time.
26+
* Query multiple Entries
27+
*
28+
* @param queryParameter Query parameter to build the query request
29+
* @return Returns a collection of matches for this query request
4130
*/
42-
Collection<Entry> get(String keyPattern, boolean includeExpired, @Nullable Instant createdRangeStart, @Nullable Instant createdRangeEnd);
43-
44-
45-
void registerListener(Listener listener);
46-
47-
default void unregisterListener(Listener listener) {
48-
unregisterListener(listener.getListenerUniqueId());
49-
}
50-
51-
void unregisterListener(UUID listenerUniqueId);
31+
Result<QueryResponse, Error> query(QueryParameter queryParameter);
5232

5333
/**
34+
* <h1>Call</h1>
35+
* <p>
5436
* Stores an object on a key with new revision in the database
5537
* and returns the stored version, including the new revision
5638
* and ID.
39+
*
40+
* <h2>Expired</h2>
41+
* If an entry is expired. For example a permission, set the expired_at field
42+
* if it's not set and the entry will be flagged as expired
43+
*
44+
* <h2>Deletion</h2>
45+
* If an entry should be deleted, just set the deleted_at field and it will be
46+
* flagged as deleted
47+
*
48+
* @param obj Object that should be saved inside the database
49+
* @return returns the created {@link studio.o7.octopus.sdk.v1.Entry}
5750
*/
58-
Entry call(Object obj);
51+
Result<Entry, Error> call(studio.o7.octopus.sdk.v1.Object obj);
5952

6053
/**
54+
* <h1>Call</h1>
55+
* <p>
6156
* Stores an object on a key with new revision in the database
6257
* and just forgets it. All listeners will be called
6358
* as usual without blocking this method.
59+
*
60+
* <h2>Expired</h2>
61+
* If an entry is expired. For example a permission, set the expired_at field
62+
* if it's not set and the entry will be flagged as expired
63+
*
64+
* <h2>Deletion</h2>
65+
* If an entry should be deleted, just set the deleted_at field and it will be
66+
* flagged as deleted
67+
*
68+
* @param obj Object that should be saved inside the database
6469
*/
65-
void callAndForget(Object obj);
70+
void write(studio.o7.octopus.sdk.v1.Object obj);
6671

72+
/**
73+
* <p>
74+
* A registration of a handler will subscribe to its given key pattern
75+
* and receive all updates on the given key pattern. The handlers `onCall`
76+
* method will be invoked on the incoming {@link studio.o7.octopus.sdk.v1.EventCall}
77+
* </p>
78+
*
79+
* <p>
80+
* When subscribing, be reminded that the key pattern really matches the requested
81+
* EventCalls, using symbols such as `*` and `<` will subscribe on multiple keys
82+
* There's no safeguard to prevent subscribing to the same topic. So please make
83+
* shure you're not handling a topic twice!
84+
* </p>
85+
*
86+
* @param eventHandler Handler that will be invoked on matching incoming event
87+
*/
88+
void registerHandler(EventHandler eventHandler);
89+
90+
/**
91+
* Unregister a handler
92+
*
93+
* @param eventHandler Handler to unregister
94+
*/
95+
default void unregisterHandler(EventHandler eventHandler) {
96+
unregisterHandler(eventHandler.getListenerUniqueId());
97+
}
98+
99+
/**
100+
* Unregister a handler
101+
*
102+
* @param listenerUniqueId ID of the handler to unregister
103+
*/
104+
void unregisterHandler(UUID listenerUniqueId);
67105
}

api/src/main/java/studio/o7/octopus/plugin/api/adapters/ComponentAdapter.java

Lines changed: 0 additions & 19 deletions
This file was deleted.

api/src/main/java/studio/o7/octopus/plugin/api/adapters/InetSocketAddressAdapter.java

Lines changed: 0 additions & 22 deletions
This file was deleted.

api/src/main/java/studio/o7/octopus/plugin/api/adapters/ItemStackAdapter.java

Lines changed: 0 additions & 23 deletions
This file was deleted.

api/src/main/java/studio/o7/octopus/plugin/api/adapters/LocationAdapter.java

Lines changed: 0 additions & 42 deletions
This file was deleted.

api/src/main/java/studio/o7/octopus/plugin/api/adapters/OfflinePlayerAdapter.java

Lines changed: 0 additions & 36 deletions
This file was deleted.

api/src/main/java/studio/o7/octopus/plugin/api/adapters/PlayerAdapter.java

Lines changed: 0 additions & 39 deletions
This file was deleted.

api/src/main/java/studio/o7/octopus/plugin/api/adapters/ResourcePackInfoAdapter.java

Lines changed: 0 additions & 28 deletions
This file was deleted.

0 commit comments

Comments
 (0)