Application architecture¶
When you create an application using the Netdef framework your application consists of:
- Exactly one engine.
- At least one rule.
- At least one source.
- At least one controller.
- At least one expression.
Glossary
- engine
The
engineis an instance ofnetdef.Engines.ThreadedEngine.
- rule
A
ruleis an instance derived fromnetdef.Rules.BaseRule.
- source
A
sourceis an instance derived fromnetdef.Sources.BaseSource.
- controller
A
controlleris an instance derived fromnetdef.Controllers.BaseController.
- expression
A python callable that is executed by
enginewhen a associated source changes its value. The associated sources are arguments to the callable. Seenetdef.Engines.expression.Expression.# Example: def expression(arg1, arg2): print("expression was called") print("This is a netdef.Engines.expression.Expression.Argument:", arg1) print("This is the associated source instance:", arg1.instance) print("The name of the associated controller:", arg1.instance.controller)
Shared queues
All instances have their own incoming queue. This queue is available
to the other instances in the shared object.
See netdef.Shared.SharedQueues.SharedQueues
The instances communicate with each other by registering messages in the recipient’s queue. The example below shows a project with one controller and one rule:
The most important message types in your application are
APP_STATE, ADD_SOURCE, ADD_PARSER, WRITE_SOURCE and
RUN_EXPRESSION. See netdef.Shared.SharedQueues.MessageType
The message flow will in most cases be as follows:
At application initialization:
- The engine will send
APP_STATEto all active controllers.- Every rule will send
ÀDD_PARSERor/andADD_SOURCEto a specific controller depending on what is in the configuration files.- The engine will send a new
APP_STATEto all active controllers.Repeats until application is terminated:
- Every controller will send
RUN_EXPRESSIONback to a specific rule on data changes.- The specific rule will then collect the associated expression to be evaluated depending on given data change and send
RUN_EXPRESSIONto the engine.- If the expression generate a new data change then a
WRITE_SOURCEmessage is sent back directly to controller.