Next Steps – Defining Agency Adapters

I’ve completed a re-write of Transit Boardâ„¢ to eliminate the server-side components and talk directly to the TriMet and NextBus arrivals web-services (in the case of NextBus, I’m using YQL, at the suggestion of my co-contributor Matt, to act as a proxy to get around cross-site data restrictions in AJAX).

Now that this is out of the way, I want to move on to a general architecture for the component we’re calling ‘Agency Adapters’. My current thinking is that there are two components per agency, a set of ‘updaters’ and an ‘updater factory’.

This thinking is based on my experience with TriMet, but I think it’s probably reasonable for covering a variety of ways that agencies may provide AVL services. It seems pretty clear to me that it will probably be necessary to allow for multiple AVL service calls per agency.

For example, with TriMet, their service will return results for up to 10 stop locations. So if my display requires 12, I’m going to need to make 2 calls. In addition, if one or more stops serves the Portland Streetcar (included in TriMet’s GTFS data, but not its AVL web service), I need to make a separate call to NextBus.

So I propose that at startup we call an ‘updater factory’ for each agency in our configuration. We would pass all the stop/line configuration information for that agency to the factory, which would in turn create and return an array of ‘updater’ objects.

Each updater would be responsible for handling all the web service calls for a specific subset of stops/lines (with the division decided by the factory). The updater would worry about issues like how frequently to call the service, logging errors, etc. and would maintain an ‘arrivals array’ with the current best set of predictions for the the delegated stops/lines.

The updater would expose an API allowing its arrivals array to be accessed, possibly along with some kind of indication of how fresh/stale they are.

The next layer up in our application stack would include a process that polls all the available updaters and builds an aggregated arrivals array.


This entry was posted in Architecture. Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *