Get a MultiPublisher for use or manually populating.
MultiPublisher provides a convenient way to publish on multiple publishers without duplicate calls to a publish() function. Options:
Empty example: add individual configured publisher to result. mp = get_multi_publisher() mp.add(...)
From environment ADC_MULTI_PUBLISHER_NAMES example m1 = get_multi_publisher(plugins=[]) m1.add(...)
From environment MY_APP_MULTI_PUBLISHER_NAMES example m1 = get_multi_publisher(plugins="MY_APP_MULTI_PUBLISHER_NAMES") m1.add(...)
Configure several plugins using environment m2 = get_multi_publisher(plugins=["stdout","http"])
Configure several plugins using environment and option overrides m3 = get_multi_publisher(plugins={"stdout":{}, "http":{"port": "8443", "url": "localhost"}})
88 plugins: str|list[str]|dict|None =None) -> publisher.MultiPublisher:
89 """! Get a MultiPublisher for use or manually populating.
90
91 MultiPublisher provides a convenient way to publish on multiple
92 publishers without duplicate calls to a publish() function.
93 Options:
94
95 @param strict If strict=True, a failure to construct any named
96 publisher will return None instead of a multipublisher, otherwise
97 failed or unknown publishers will be silently ignored.
98
99 @param plugins can be one of:
100 - None, which then constructs plugins using the name list from
101 env("ADC_MULTI_PUBLISHER_NAMES") and their environment-defined
102 or default options.
103 If ADC_MULTI_PUBLISHER_NAMES is unset, an empty MultiPublisher ready
104 to configure is returned.
105 - A string naming an alternative environment variable to ADC_MULTI_PUBLISHER_NAMES.
106 E.g. a library foo may use FOO_MULTI_PUBLISHER_NAMES.
107 - A list of names from among those returned by get_publisher_names,
108 where each named plugin is configured from environment-defined or
109 default options. An empty list is treated as None.
110 - A dictionary of dictionaries, where the top keys are plugin names and
111 the dictionary values are as documented in each plugin.
112
113 Empty example: add individual configured publisher to result.
114 mp = get_multi_publisher()
115 mp.add(...)
116
117 From environment ADC_MULTI_PUBLISHER_NAMES example
118 m1 = get_multi_publisher(plugins=[])
119 m1.add(...)
120
121 From environment MY_APP_MULTI_PUBLISHER_NAMES example
122 m1 = get_multi_publisher(plugins="MY_APP_MULTI_PUBLISHER_NAMES")
123 m1.add(...)
124
125 Configure several plugins using environment
126 m2 = get_multi_publisher(plugins=["stdout","http"])
127
128 Configure several plugins using environment and option overrides
129 m3 = get_multi_publisher(plugins={"stdout":{},
130 "http":{"port": "8443", "url": "localhost"}})
131
132 """
133 return publisher.MultiPublisher(strict, plugins)
134