Subj - how could I allow\disallow actions in my system based on the state of another external system (I have access to it's state via the shared DB table)? I can get the state of another system almost immediately, another system is like a state machine with some states like 'running', 'maintenance', 'initializing' etc.
For example there are some of my commands and queries
If external system is in state 'initializing' I want to prohibit calling of
ChangeStateOfExternalSystem, but allow to call
DoSomethingWithExternalSystem1 and like so many other cases. Some of them should also return OK status for some specific states without actually executing underlying method. Also important point - state of external system could be changed inside my commands sometimes. For example command could switch system from the state 'maintenance' to state 'running' and so on.
Could someone suggest me the preffered approach to this problem? Maybe there are some patterns which could be used to bypass my problem?