Skip to content

sjrct's route implementation#105

Closed
sjrct wants to merge 2 commits into
masterfrom
sjrct-routes
Closed

sjrct's route implementation#105
sjrct wants to merge 2 commits into
masterfrom
sjrct-routes

Conversation

@sjrct

@sjrct sjrct commented Nov 10, 2017

Copy link
Copy Markdown
Member

This is a potential implementation. there are other options that are being discussed.

This flavor uses the '@' prefix to mark what is an is not a container or alias (an intermediary destination).

Example of routes key:

"routes": [
  { "@container": [ "module1", "module2" ]
  , "@container2": [ "@container", "secret-module" ]
  , "special-agent-1": "@container2"
  , "special-agent-2": "@container2"
  },
  { ".*": "@container"
  }
]

This flavor uses the '@' prefix to mark what is an is not a
container or alias (an intermediary destination).
@sjrct sjrct added the RFC label Nov 10, 2017
As without any routes declared nothing will be routed anywhere
(different behavoir from before), add_route needs to be called
explicitly in some places. Also, need to have config on a instance
rather than class basis so routes do not bleed from one test case into
another.
@coveralls

coveralls commented Nov 10, 2017

Copy link
Copy Markdown

Coverage Status

Coverage decreased (-0.2%) to 94.507% when pulling ed422ff on sjrct-routes into fa73d77 on master.

@richteer

Copy link
Copy Markdown
Contributor

I pushed my (unfinished) branch to richteer-routes. Will maybe open a PR if I bother to finish it.

@richteer

Copy link
Copy Markdown
Contributor

Notes from meeting: implement special case container @modules and @agents. Default route should be @agents -> @modules

@richteer

richteer commented Nov 15, 2017

Copy link
Copy Markdown
Contributor

Suggestion for the .route() function to reduce some indentation:

	def route(self, source, resolve_all=False):
		for d in self.config.get('routes', []):
			dest = []

			# Find all matching patterns of the same precedence level
			meep = [p for p in d if re.match(p, source)]
			if not meep:
				continue
			for pat in meep:
				raw = d[pat] if type(d[pat]) == list else [ d[pat] ]
				for ri in raw:
					name = ri.split('/')[0]
					if ri.startswith('@') and (resolve_all or not name in self.objects):
						# Resolve aliases
						dest.extend(self.route(ri))
					else:
						dest.append(ri)
			return dest

		return []

@richteer richteer added the stale label Mar 5, 2019
@sjrct

sjrct commented Oct 15, 2019

Copy link
Copy Markdown
Member Author

there is no way this is ever getting merged

@sjrct sjrct closed this Oct 15, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants