temporary commit
This commit is contained in:
@@ -5,6 +5,7 @@ plugins {
|
||||
}
|
||||
|
||||
dependencies {
|
||||
api catalog.netty.buffer
|
||||
}
|
||||
|
||||
publishing {
|
||||
|
@@ -1,6 +1,8 @@
|
||||
module net.woggioni.gbcs.api {
|
||||
requires static lombok;
|
||||
requires java.xml;
|
||||
requires io.netty.buffer;
|
||||
exports net.woggioni.gbcs.api;
|
||||
exports net.woggioni.gbcs.api.exception;
|
||||
exports net.woggioni.gbcs.api.event;
|
||||
}
|
@@ -3,10 +3,10 @@ package net.woggioni.gbcs.api;
|
||||
import net.woggioni.gbcs.api.exception.ContentTooLargeException;
|
||||
|
||||
import java.nio.channels.ReadableByteChannel;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
|
||||
|
||||
public interface Cache extends AutoCloseable {
|
||||
ReadableByteChannel get(String key);
|
||||
|
||||
void put(String key, byte[] content) throws ContentTooLargeException;
|
||||
CompletableFuture<CallHandle<Void>> get(String key, ResponseEventListener responseEventListener);
|
||||
CompletableFuture<CallHandle<Void>> put(String key) throws ContentTooLargeException;
|
||||
}
|
||||
|
10
gbcs-api/src/main/java/net/woggioni/gbcs/api/CallHandle.java
Normal file
10
gbcs-api/src/main/java/net/woggioni/gbcs/api/CallHandle.java
Normal file
@@ -0,0 +1,10 @@
|
||||
package net.woggioni.gbcs.api;
|
||||
|
||||
import net.woggioni.gbcs.api.event.RequestEvent;
|
||||
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
|
||||
public interface CallHandle<T> {
|
||||
void postEvent(RequestEvent evt);
|
||||
CompletableFuture<T> call();
|
||||
}
|
@@ -0,0 +1,7 @@
|
||||
package net.woggioni.gbcs.api;
|
||||
|
||||
import net.woggioni.gbcs.api.event.ResponseEvent;
|
||||
|
||||
public interface ResponseEventListener {
|
||||
void listen(ResponseEvent evt);
|
||||
}
|
@@ -0,0 +1,20 @@
|
||||
package net.woggioni.gbcs.api.event;
|
||||
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import lombok.Getter;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import net.woggioni.gbcs.api.CallHandle;
|
||||
|
||||
sealed public abstract class RequestEvent {
|
||||
@Getter
|
||||
@RequiredArgsConstructor
|
||||
public static final class ChunkSent extends RequestEvent {
|
||||
private final ByteBuf chunk;
|
||||
}
|
||||
|
||||
@Getter
|
||||
@RequiredArgsConstructor
|
||||
public static final class LastChunkSent extends RequestEvent {
|
||||
private final ByteBuf chunk;
|
||||
}
|
||||
}
|
@@ -0,0 +1,28 @@
|
||||
package net.woggioni.gbcs.api.event;
|
||||
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import lombok.Getter;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
|
||||
sealed public abstract class ResponseEvent {
|
||||
@Getter
|
||||
@RequiredArgsConstructor
|
||||
public final static class ChunkReceived extends ResponseEvent {
|
||||
private final ByteBuf chunk;
|
||||
}
|
||||
|
||||
public final static class NoContent extends ResponseEvent {
|
||||
}
|
||||
|
||||
@Getter
|
||||
@RequiredArgsConstructor
|
||||
public final static class LastChunkReceived extends ResponseEvent {
|
||||
private final ByteBuf chunk;
|
||||
}
|
||||
|
||||
@Getter
|
||||
@RequiredArgsConstructor
|
||||
public final static class ExceptionCaught extends ResponseEvent {
|
||||
private final Throwable cause;
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user