File tree Expand file tree Collapse file tree 1 file changed +21
-0
lines changed
Expand file tree Collapse file tree 1 file changed +21
-0
lines changed Original file line number Diff line number Diff line change @@ -11,6 +11,22 @@ using namespace trygvis::mqtt_support;
1111
1212namespace msgflo {
1313
14+ std::string random_string ( size_t length )
15+ {
16+ auto randchar = []() -> char
17+ {
18+ const char charset[] =
19+ " 0123456789"
20+ " ABCDEFGHIJKLMNOPQRSTUVWXYZ"
21+ " abcdefghijklmnopqrstuvwxyz" ;
22+ const size_t max_index = (sizeof (charset) - 1 );
23+ return charset[ rand () % max_index ];
24+ };
25+ std::string str (length,0 );
26+ std::generate_n ( str.begin (), length, randchar );
27+ return str;
28+ }
29+
1430std::string string_to_upper_copy (const std::string &str) {
1531 std::string ret;
1632 ret.resize (str.size ());
@@ -145,6 +161,11 @@ class AbstractEngine {
145161
146162 Definition validateDefinitionFromUser (const Definition &definition) {
147163 Definition d (definition);
164+
165+ if (d.id .size () == 0 ) {
166+ d.id = d.role + " -" + random_string (8 );
167+ }
168+
148169 for (auto &port : d.inports ) {
149170 if (port.queue .empty ()) {
150171 port.queue = generateQueueName (definition, port);
You can’t perform that action at this time.
0 commit comments