-
Notifications
You must be signed in to change notification settings - Fork 0
@Include
The include decorator tells the command-line interface that it should also compile the class object that was passed in the ref parameter. This is particularity useful for instances of TimeperiodObj where the object is not referenced in the class instance but in the decorator object definition instead.
ref: NagiosObj|InheritableNagiosObj an instance of an object which implements NagiosObj or InheritableNagiosObj interfaces.
If we have a '24x7' time period, we might want to refer to it in the decorator:
@Host({
host_name: 'localhost',
address: '127.0.0.1',
check_interval: 5,
retry_interval: 1,
max_check_attempts: 5,
check_period: '24x7',
process_perf_data: false,
retain_nonstatus_information: false,
notification_interval: 0,
notification_period: '24x7',
notification_options: 'd,u,r'
})
export class Localhost extends HostObj {}If we are to omit the @Include decorator on th host, Nagios will not be able to resolve the check_period: '24x7' time period reference because the time period object definition will not exist. We can resolve this with the @Include decorator:
@Host({
host_name: 'localhost',
address: '127.0.0.1',
check_interval: 5,
retry_interval: 1,
max_check_attempts: 5,
check_period: '24x7',
process_perf_data: false,
retain_nonstatus_information: false,
notification_interval: 0,
notification_period: '24x7',
notification_options: 'd,u,r'
})
@Include(DefaultTimeperiod)
export class Localhost extends HostObj {}It is important to note that the
refattribute only excepts class instances, not types. TheDefaultTimeperiodreference mentioned in the example is actually the default export of a TimeperiodObj instance, defined asexport default const DefaultTimeperiod = new DefaultTimeperiod();. Check out the DefaultTimeperiod class for the full example.
Made in Amsterdam with ♥
Special thanks to

