Added Obsidian Module

Obsidian HTTPD module replacement
This commit is contained in:
Paul Reilly 2023-06-30 15:03:07 -05:00
parent 2b12f4eebb
commit eba1df51ee
24 changed files with 399 additions and 5 deletions

View File

@ -16,6 +16,8 @@ dependencies {
testImplementation 'org.junit.jupiter:junit-jupiter'
}
var buildOrder = 2;
test {
useJUnitPlatform()
}

118
Obsidian/.gitignore vendored Normal file
View File

@ -0,0 +1,118 @@
# User-specific stuff
.idea/
*.iml
*.ipr
*.iws
# IntelliJ
out/
# mpeltonen/sbt-idea plugin
.idea_modules/
# JIRA plugin
atlassian-ide-plugin.xml
# Compiled class file
*.class
# Log file
*.log
# BlueJ files
*.ctxt
# Package Files #
*.jar
*.war
*.nar
*.ear
*.zip
*.tar.gz
*.rar
# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
hs_err_pid*
*~
# temporary files which can be created if a process still has a handle open of a deleted file
.fuse_hidden*
# KDE directory preferences
.directory
# Linux trash folder which might appear on any partition or disk
.Trash-*
# .nfs files are created when an open file is removed but is still being accessed
.nfs*
# General
.DS_Store
.AppleDouble
.LSOverride
# Icon must end with two \r
Icon
# Thumbnails
._*
# Files that might appear in the root of a volume
.DocumentRevisions-V100
.fseventsd
.Spotlight-V100
.TemporaryItems
.Trashes
.VolumeIcon.icns
.com.apple.timemachine.donotpresent
# Directories potentially created on remote AFP share
.AppleDB
.AppleDesktop
Network Trash Folder
Temporary Items
.apdisk
# Windows thumbnail cache files
Thumbs.db
Thumbs.db:encryptable
ehthumbs.db
ehthumbs_vista.db
# Dump file
*.stackdump
# Folder config file
[Dd]esktop.ini
# Recycle Bin used on file shares
$RECYCLE.BIN/
# Windows Installer files
*.cab
*.msi
*.msix
*.msm
*.msp
# Windows shortcuts
*.lnk
.gradle
build/
# Ignore Gradle GUI config
gradle-app.setting
# Cache of project
.gradletasknamecache
**/build/
# Common working directory
run/
# Avoid ignoring Gradle wrapper jar file (.jar files are usually ignored)
!gradle-wrapper.jar

27
Obsidian/build.gradle Normal file
View File

@ -0,0 +1,27 @@
plugins {
id 'java'
}
group = 'me.totalfreedom'
version = '1.0'
repositories {
mavenCentral()
maven {
name = "spigotmc-repo"
url = "https://hub.spigotmc.org/nexus/content/repositories/snapshots/"
}
maven {
name = "sonatype"
url = "https://oss.sonatype.org/content/groups/public/"
}
}
dependencies {
compileOnly "org.spigotmc:spigot-api:1.20.1-R0.1-SNAPSHOT"
compileOnly "io.projectreactor:reactor-core:3.5.7"
implementation "org.jetbrains:annotations:23.0.0"
implementation "com.google.errorprone:error_prone_annotations:2.11.0"
}
var buildOrder = 0;

View File

@ -0,0 +1,9 @@
package me.totalfreedom.obsidian.core;
public interface Disposable
{
void dispose();
boolean isDisposed();
}

View File

@ -0,0 +1,5 @@
package me.totalfreedom.obsidian.core;
public interface Observable<T> {
void subscribe(Observer<T> observer);
}

View File

@ -0,0 +1,11 @@
package me.totalfreedom.obsidian.core;
public interface Observer<T>
{
void onNext(T item);
void onError(Throwable throwable);
void onComplete();
}

View File

@ -0,0 +1,15 @@
package me.totalfreedom.obsidian.core;
import java.util.concurrent.TimeUnit;
public interface Scheduler
{
Disposable schedule(Runnable task);
Disposable schedule(Runnable task, long delay, TimeUnit unit);
Disposable schedulePeriodically(Runnable task, long initialDelay, long period, TimeUnit unit);
void dispose();
}

View File

@ -0,0 +1,8 @@
package me.totalfreedom.obsidian.http;
import reactor.core.publisher.Mono;
public interface WebClient {
Mono<WebResponse> sendRequest(WebRequest request);
}

View File

@ -0,0 +1,8 @@
package me.totalfreedom.obsidian.http;
import reactor.core.publisher.Mono;
public interface WebHandler {
Mono<WebResponse> handleRequest(WebRequest request);
}

View File

@ -0,0 +1,20 @@
package me.totalfreedom.obsidian.http;
import java.util.List;
import java.util.Set;
public interface WebHeaders
{
List<String> getHeader(String name);
void addHeader(String name, String value);
void setHeader(String name, String value);
void removeHeader(String name);
boolean containsHeader(String name);
Set<String> getHeaderNames();
}

View File

@ -0,0 +1,12 @@
package me.totalfreedom.obsidian.http;
public enum WebMethod {
GET,
POST,
PUT,
DELETE,
PATCH,
HEAD,
OPTIONS
}

View File

@ -0,0 +1,15 @@
package me.totalfreedom.obsidian.http;
import java.awt.image.DataBuffer;
import java.nio.ByteBuffer;
import reactor.core.publisher.Flux;
import reactor.core.publisher.Mono;
public interface WebRequest {
WebMethod getMethod();
String getUri();
WebHeaders getHeaders();
Mono<ByteBuffer> getBody();
Flux<DataBuffer> getBodyFlux();
}

View File

@ -0,0 +1,17 @@
package me.totalfreedom.obsidian.http;
import java.awt.image.DataBuffer;
import java.nio.ByteBuffer;
import reactor.core.publisher.Flux;
import reactor.core.publisher.Mono;
public interface WebResponse {
WebStatus getStatus();
WebHeaders getHeaders();
void setStatus(WebStatus status);
void setHeader(String name, String value);
Mono<Void> write(ByteBuffer data);
Mono<Void> write(DataBuffer dataBuffer);
Mono<Void> write(Flux<DataBuffer> dataFlux);
}

View File

@ -0,0 +1,9 @@
package me.totalfreedom.obsidian.http;
public interface WebServer {
void start();
void stop();
void registerHandler(String uri, WebHandler handler);
void unregisterHandler(String uri);
}

View File

@ -0,0 +1,26 @@
package me.totalfreedom.obsidian.http;
public enum WebStatus
{
OK(200),
CREATED(201),
NO_CONTENT(204),
BAD_REQUEST(400),
UNAUTHORIZED(401),
FORBIDDEN(403),
NOT_FOUND(404),
INTERNAL_SERVER_ERROR(500);
private final int code;
WebStatus(final int code)
{
this.code = code;
}
public int getCode()
{
return code;
}
}

View File

@ -0,0 +1,15 @@
package me.totalfreedom.obsidian.security;
public interface OAuth2Credentials
{
String getClientId();
String getClientSecret();
String getUsername();
String getPassword();
String getScope();
}

View File

@ -0,0 +1,12 @@
package me.totalfreedom.obsidian.security;
import reactor.core.publisher.Mono;
public interface OAuth2Service
{
Mono<OAuth2Token> authenticate(OAuth2Credentials credentials);
Mono<Boolean> validateToken(OAuth2Token token);
Mono<OAuth2Token> refreshAccessToken(OAuth2Token token);
}

View File

@ -0,0 +1,22 @@
package me.totalfreedom.obsidian.security;
import java.time.Instant;
public interface OAuth2Token
{
String getAccessToken();
void setAccessToken(String accessToken);
String getRefreshToken();
void setRefreshToken(String refreshToken);
String getTokenType();
void setTokenType(String tokenType);
Instant getExpiresAt();
void setExpiresAt(Instant expiresAt);
}

View File

@ -0,0 +1,13 @@
package me.totalfreedom.obsidian.sql;
import reactor.core.publisher.Mono;
public interface SQLConnection
{
Mono<SQLResult> executeQuery(SQLQuery query);
Mono<Integer> executeUpdate(SQLQuery query);
void close();
}

View File

@ -0,0 +1,10 @@
package me.totalfreedom.obsidian.sql;
import java.util.List;
public interface SQLQuery {
String getQuery();
List<Object> getParameters();
void setParameter(int index, Object value);
}

View File

@ -0,0 +1,8 @@
package me.totalfreedom.obsidian.sql;
public interface SQLResult
{
boolean next();
<T> T getColumn(int index, Class<T> type);
}

View File

@ -0,0 +1,7 @@
name: Obsidian
version: '${version}'
main: me.totalfreedom.obsidian.Obsidian
api-version: '1.20'
load: STARTUP
libraries:
- io.projectreactor:reactor-core:3.5.4

View File

@ -52,19 +52,23 @@ subprojects {
useJUnitPlatform()
}
var weight = -1;
var buildOrder = -1;
afterEvaluate {
if (weight == -1) {
weight = 0
if (buildOrder == -1) {
buildOrder = 0
}
}
}
tasks.register('buildChain') {
dependsOn subprojects.sort {
a, b -> a.properties.weight <=> b.properties.weight
dependsOn subprojects.sort { a, b ->
def buildOrderA = a.hasProperty('buildOrder') ? a.buildOrder : 0
def buildOrderB = b.hasProperty('buildOrder') ? b.buildOrder : 0
buildOrderA <=> buildOrderB
}.collect {
":${it.path}:build"
}
}

View File

@ -3,4 +3,5 @@ include 'Patchwork'
include 'Datura'
include 'Fossil'
include 'Corvo'
include 'Obsidian'