Skip to content
This repository has been archived by the owner on Dec 18, 2023. It is now read-only.
/ Shielder Public archive

A small, simple, asynchronous utility for constraining arbitrary tasks within CPU and RAM limitations. Additionally provides a wrapper for the JSR-223 specification to sandbox scripting functionality.

License

Notifications You must be signed in to change notification settings

danthonywalker/Shielder

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Shielder

A small, simple, asynchronous utility for constraining arbitrary tasks within CPU and RAM limitations. Additionally provides a wrapper for the JSR-223 specification to sandbox scripting functionality.

Dependency

Maven

<repositories>
    <repository>
        <id>jitpack.io</id>
        <url>https://jitpack.io</url>
    </repository>
</repositories>

<dependency>
    <groupId>com.github.neontech.shielder</groupId>
    <artifactId>shielder-core</artifactId>
    <!-- <artifactId>shielder-jsr223</artifactId> -->
    <version>${version}</version>
</dependency>

Gradle

repositories {
    maven { url 'https://jitpack.io' }
}

dependencies {
    implementation 'com.github.neontech.shielder:shielder-core:$version'
    // implementation `com.github.neontech.shielder:shielder-jsr223:$version`
}

Getting Started

shielder-core

final var sandbox = Sandbox.create();
final var environment = SandboxEnvironment.builder()
    .setCpuLimit(Duration.ofSeconds(1))
    .setRamLimit(1000000)
    .build();

final Callable<T> taskToSandbox = ...
final CompletableFuture<T> future = sandbox.startTask(environment, taskToSandbox);

shielder-jsr223

final var manager = new ShielderScriptEngineManager();

manager can be treated exactly like a ScriptEngineManager. Everything created by the manager is executed in a Sandbox which can be accessed by invoking manager.getSandbox().

To change the SandboxEnvironment for a specific ScriptContext, use the ShielderScriptEngine.SANDBOX_ENVIRONMENT attribute and simply provide a SandboxEnvironment instance as its value.

About

A small, simple, asynchronous utility for constraining arbitrary tasks within CPU and RAM limitations. Additionally provides a wrapper for the JSR-223 specification to sandbox scripting functionality.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages