paritytech / orchestra

A partial actor pattern with a global orchestrator.
GNU General Public License v3.0
27 stars 3 forks source link

Feature gating subsystems via `#[cfg]` #41

Closed skunert closed 1 year ago

skunert commented 1 year ago

In this PR I introduce guarding of subsystems via features. Supported syntax:

#[orchestra(signal=Signal, event=ExternalEvent, error=SubsystemError, gen=AllMessages)]
struct MyOverseer<T, U, V, W> {
    #[cfg(feature = "feature1")]
    #[subsystem(consumes: Subsystem1Message, sends: [Subsystem2Message])]
    subsystem1: Sub1,

    #[subsystem(consumes: Subsystem2Message, sends: [Subsystem1Message])]
    subsystem2: Sub2,
}

Basically this allows re-use of one orchestra in scenarios where it is not needed to run all subsystems. The #cfg attribute macro currently supports any, all, not and feature = "something".

Limitations

skunert commented 1 year ago

Q: do we want to allow arbitrary #[] macros eventually? I.e. copying derive over to the generated struct only and keeping any other ones on all items. But that's for another time I think.

Not sure I understand, how could this be used?