Package org.nanonative.nano.core
Class Nano
-
Field Summary
Fields inherited from class org.nanonative.nano.core.NanoServices
servicesFields inherited from class org.nanonative.nano.core.NanoThreads
schedulersFields inherited from class org.nanonative.nano.core.NanoBase
CONFIG_KEYS, context, createdAtMs, EVENT_ID_COUNTER, EVENT_TYPES, eventCount, isReady, listeners, logService -
Constructor Summary
ConstructorsConstructorDescriptionNano(berlin.yuna.typemap.model.FunctionOrNull<Context, List<Service>> startupServices, Map<Object, Object> config, String... args) Nano(String[] args, berlin.yuna.typemap.model.FunctionOrNull<Context, List<Service>> startupServices) -
Method Summary
Modifier and TypeMethodDescriptionprotected voidcontext()Returns the rootContext.Creates aContextspecified class.contextEmpty(Class<?> clazz) Creates an emptyContextfor the specified class.protected voidprotected voidgracefulShutdown(Context context) hostname()protected voidvoidPrints the configurations that have been loaded into theNanoinstance.Prints system information for diagnostic purposes.Sends an event with the specified parameters, either broadcasting it to all listeners or sending it to a targeted listener asynchronously if a response listener is provided.sendEventR(Event event) Processes an event with the given parameters and decides on the execution path based on the presence of a response listener and the broadcast flag.sendEventSameThread(Event event) Sends an event on the same thread and determines whether to process it to the first listener.protected NanoShuts down theNanoinstance, ensuring all services and threads are gracefully terminated.protected NanoShuts down theNanoinstance, ensuring all services and threads are gracefully terminated.protected voidstartServicesAndLogger(berlin.yuna.typemap.model.FunctionOrNull<Context, List<Service>> startupServices) Initiates the shutdown process for theNanoinstance.Initiates the shutdown process for theNanoinstance.toString()This method blocks the current thread for max 10 seconds until theNanoinstance is no longer ready.Methods inherited from class org.nanonative.nano.core.NanoServices
registerService, service, serviceOpt, services, services, shutdownServices, unregisterServiceMethods inherited from class org.nanonative.nano.core.NanoThreads
asyncFromPool, executeScheduler, kill, removeScheduler, run, run, run, runAsync, schedulers, shutdownExecutors, shutdownThreadsMethods inherited from class org.nanonative.nano.core.NanoBase
createdAtMs, displayHelpMenu, eventCount, heapMemoryUsage, isReady, listeners, pid, putAll, readConfigs, standardiseKey, subscribeEvent, unsubscribeEvent, usedMemoryMB
-
Constructor Details
-
Nano
-
Nano
- Parameters:
args- Command-line arguments passed during the application start.startupServices- Varargs parameter of startupServiceto be initiated.
-
Nano
- Parameters:
config- Map of configuration parameters.startupServices- Varargs parameter of startupServiceto be initiated.
-
Nano
public Nano(Map<Object, Object> config, berlin.yuna.typemap.model.FunctionOrNull<Context, List<Service>> startupServices) - Parameters:
config- Map of configuration parameters.startupServices- Function to provide startupServicebased on the given context.
-
Nano
public Nano(String[] args, berlin.yuna.typemap.model.FunctionOrNull<Context, List<Service>> startupServices) - Parameters:
args- Command-line arguments passed during the application start.startupServices- Function to provide startupServicebased on the given context.
-
Nano
public Nano(berlin.yuna.typemap.model.FunctionOrNull<Context, List<Service>> startupServices, Map<Object, Object> config, String... args) InitializesNanowith a function to provide startupService, configurations, and command-line arguments.- Parameters:
startupServices- Function to provide startupServicebased on the given context.config- Map of configuration parameters.args- Command-line arguments passed during the application start.
-
-
Method Details
-
context
Returns the rootContext. This context should be only used to manipulate values.context()should be used for running Lambdas,Services,Schedulers or sendEvents- Returns:
- the root
Contextassociated.
-
context
Creates aContextspecified class. -
contextEmpty
Creates an emptyContextfor the specified class. -
stop
Initiates the shutdown process for theNanoinstance. -
stop
Initiates the shutdown process for theNanoinstance. -
waitForStop
This method blocks the current thread for max 10 seconds until theNanoinstance is no longer ready. This is useful in tests for ensuring that the application has fully stopped before proceeding with further operations.- Returns:
- The current instance of
Nanofor method chaining.
-
printParameters
public void printParameters()Prints the configurations that have been loaded into theNanoinstance. -
sendEvent
Sends an event with the specified parameters, either broadcasting it to all listeners or sending it to a targeted listener asynchronously if a response listener is provided.- Parameters:
event- TheEventobject that encapsulates the event's context, type, and payload. useEvent.eventOf(Context, int)to create an instance.- Returns:
- The
Nanoinstance, allowing for method chaining.
-
sendEventR
Processes an event with the given parameters and decides on the execution path based on the presence of a response listener and the broadcast flag. If a response listener is provided, the event is processed asynchronously; otherwise, it is processed in the current thread. This method creates anEventinstance and triggers the appropriate event handling logic.- Parameters:
event- TheEventobject that encapsulates the event's context, type, and payload. useEvent.eventOf(Context, int)to create an instance.- Returns:
- An instance of
Eventthat represents the event being processed. This object can be used for further operations or tracking.
-
sendEventSameThread
Sends an event on the same thread and determines whether to process it to the first listener. UsedContext.sendEvent(int, Supplier)fromcontext(Class)instead of the core method.- Parameters:
event- The event to be processed.- Returns:
- self for chaining
-
shutdown
Shuts down theNanoinstance, ensuring all services and threads are gracefully terminated.- Parameters:
clazz- class for which theContextis to be created.- Returns:
- Self for chaining
-
cleanUps
-
printActiveProfiles
protected void printActiveProfiles() -
startServicesAndLogger
-
shutdown
Shuts down theNanoinstance, ensuring all services and threads are gracefully terminated. -
hostname
-
printSystemInfo
Prints system information for diagnostic purposes. Similar totoString()- Returns:
- Self for chaining
-
gracefulShutdown
-
exit
-
toString
-