Releases: ShindouMihou/Nexus
v1.0.0-alpha3.10
This patch introduces several critical memory and computation solutions that can affect one application:
- Indexing is now more efficient and straightforward with the new indexing methods which also aim to reduce costly indexes by referencing commands to their UUIDs instead of the actual command themselves. This should hopefully save up some memory usage.
- A critical issue with paginators was solved where destroying the paginator does not clear up its listeners, leading to objects inside the listeners not being dereferenced.
- A critical issue with responders was also solved where methods such as
getEphemeral
andget
were spawning their own responders onto the repository when it's no longer needed. This is one of the major factors of memory leaks.
I recommend updating to this version ASAP to solve many of the issues that you may encounter at scale.
v1.0.0-alpha3.09
This minor patch enables developers to customize the methods for synchronizing commands, in case of which that you are using a custom fork of Javacord that supports different arguments. You can refer to the following over how to implement:
To tell Nexus to use your customized methods, make sure that you add this line BEFORE ANY FORM OF SYNCHRONIZATION:
NexusSynchronizer.SYNCHRONIZE_METHODS.set(<Your Synchronize Methods Class>);
v1.0.0-alpha3.08
This patch fixes a critical CPU leak from Nexus' EngineX:
- EngineX has been refactored to passively push the events straight to the DiscordApi if the shard manager has it non-null instead of going through a queue loop which was hugely inefficient. It will still process through a queue if there were events that were pushed before the shard was active. (tested and verified in production with https://manabot.fun with results going from 90% CPU usage stable to 2-5% CPU usage [including the bot's functions])
v1.0.0-alpha3.07
This patch adds the following changes:
- Add support for
respondLaterAsEphemeralIf(...)
onNexusCommandEvent
. - Add support for ephemeral delay response on middlewares.
v1.0.0-alpha3.06.5
This patch adds two new methods for NexusCommandEvent
to make the life of the developers easier:
- Added
respondLaterAsEphemeralIf(...)
methods
v1.0.0-alpha3.06
This patch adds the following bit improvement, fixes, and changes:
- Added
NexusConsoleLoggingAdapter
which can be used for users that do not use SLF4J but still want something similar for Nexus. It is configurable from the format, date-time format, and the allowed-disallowed logging levels. -
NexusSynchronizer
should now complete exceptionally whenever a server is missing while doingupsert
,delete
, etc... This is somehow a case on Javacord in which the server is possibly unavailable when EngineX kicks in or when you place the wrongtotalShards
value. - To assist with fixing the above, EngineX will now delay all queued Nexus shard events such as synchronization for 2 seconds during the time the shard was added, this is to give Javacord some time to initialize the servers if possible.
How to use the Console Logging Adapter?
The console logging adapter is customizable enough for one's liking and can therefore be used, but we provide default configurations that follows Javacord's logging style with an example of the logging message being:
2022-03-09 15:57:20.493+0800 INFO Nexus You have received the message: Hello World
You can configure Nexus to use this logging adapter with a single line of code:
Nexus.setLogger(new NexusConsoleLoggingAdapter(new NexusConsoleLoggingConfiguration()));
The default configuration follows the specific configuration:
-
$_DATE $_LEVEL Nexus $_MESSAGE
format - A default date-time format of
yyyy-MM-dd HH:mm:ss.SSSZ
.
Customizing Formats
You can customize the format but keep the default date-time format by creating a new instance with this:
new NexusConsoleLoggingConfiguration(
"$_DATE $_LEVEL Nexus is Potato! $_MESSAGE"
)
This will create a configuration that has the following:
-
$_DATE $_LEVEL Nexus is Potato! $_MESSAGE
format which translates into2022-03-09 15:57:20.493+0800 INFO Nexus is Potato! You have received the message: Hello World
. - A default date-time format of
yyyy-MM-dd HH:mm:ss.SSSZ
.
You can customize the date-time format but keep the default logging format by creating a new instance with this:
new NexusConsoleLoggingConfiguration(
DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss.SSSZ")
)
You can also customize both of them at the same time if you wish by creating a new instance like this:
new NexusConsoleLoggingConfiguration(
"$_DATE $_LEVEL Nexus is Potato! $_MESSAGE",
DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss.SSSZ")
)
You can disable date-time formatting by either not including $_DATE
in the format or by setting the date-time format as null
.
Customizing Logging Levels
If you want to enable DEBUG logging level then you can use the method:
new NexusConsoleLoggingConfiguration().allow(NexusConsoleLoggingLevel.DEBUG);
If you want to prevent the logging of a specific level, for instance, INFO then you can use the method:
new NexusConsoleLoggingConfiguration().disallow(NexusConsoleLoggingLevel.INFO);
If you want to set specific logging levels without using disallow
everytime then you can use this method:
new NexusConsoleLoggingConfiguration().set(NexusConsoleLoggingLevel.ERROR, NexusConsoleLoggingLevel.WARN);
1.0.0-alpha3.05
This patch introduces a lot of breaking changes, major improvements, and fixes in the areas of:
- Middlewares
- User, Roles, Permissions Command Authentication
- Commands
🍶 Changes
- Introduced support for shared fields which can be used to store data in commands that are shared towards middleware and afterwares, especially handy for middleware or afterware that requires data in the command itself such as cooldown middleware and so forth. You can view examples of this in action with the new command authentication middleware and also the examples.
- Pre-built authentication functionality has been removed in favor of the new new command authentication middleware which allows users to create their own authentication middleware to override the default behavior.
- Uncaught exceptions that are thrown during middleware or afterwares execution is now printed to console.
- Added
NexusInterceptorRepository
to replacestatic
method addition of middleware and afterwares. - Added unit tests for command generation to ensure that all the commands are generated properly after a new change.
📦 Migrating to alpha-3.0.5
The breaking change of alpha-3.0.5
lies in the removal of the half-baked, built-in authentication methods which are improved upon and made non-mandatory like the ratelimiters. If you are using these authentication methods then all you have to do is make the fields shared using the @Share
annotation then add the middleware: NexusCommonInterceptors.NEXUS_AUTH_<TYPE>_MIDDLEWARE
with <TYPE>
being what authentication method you were using. An example would be:
Before
private final List<Long> requiredUsers = List.of(...);
After
@Share private final List<Long> requiredUsers = List.of(...)
private final List<String> middleware = List.of(NexusCommonInterceptors.NEXUS_AUTH_PERMISSIONS_MIDDLEWARE, ...);
Fix interceptors not found
This patch fixes an issue where common interceptors weren't being added because the static method was not being called by Java since there were no main methods or similar triggering the class to function.
Fix private common interceptors
This patch fixes a known issue where some common interceptors that should be a public static were made into a private static.
Ratelimit Middleware
Ratelimit Middleware Patch
This patch introduces a new standard and also fixes a known issue with the previous rate-limiter implementation which doesn't take middleware into consideration, this newer standard makes rate-limiters as a middleware to fully utilize the middleware functionality and also to allow developers to create their own rate-limiters with the data available.
The cooldown
field is kept for several reasons:
- It is still used by the middleware itself.
- It can be used by developers to introduce their own middleware for rate-limiting.
How to add the default rate-limiter as a middleware?
Adding the rate-limiter middleware is simple and easy, all you need is to have a Nexus
instance or even just create a new instance of the NexusRatelimiter
yourself but we recommend using the Nexus
instance's own rate limiter middleware which can be added to your command by adding this as a middleware:
NexusCommonInterceptors.NEXUS_RATELIMITER
You can add it to a command by adding this field in your command class:
List<String> middlewares = List.of(NexusCommonInterceptors.NEXUS_RATELIMITER, ...);
You can also add it as a global middleware by using the Nexus
instance's addGlobalMiddleware
function:
Nexus nexus = ...
nexus.addGlobalMiddleware(NexusCommonInterceptors.NEXUS_RATELIMITER);