Skip to content
Sebastian Riedel edited this page Mar 20, 2017 · 2 revisions

Project ideas

Caching proxy

Random thoughts which should not be lost:

  • Timestamp - Mini description - Timeframe for Completion - Proposed by - Link to IRC

  • 2017-03-01 19:26 UTC - A Mojolicious test module for effortless testing of remote service clients - "Maybe next hackweek when no one beets me to it" - sri - https://irclog.perlgeek.de/mojo/2017-03-01#i_14188172

      19:02 sri             btw. here's an idea for a new mojolicious test module, a proxy app that forwards requests to a remote service, and then caches results in a local cache directory in flat files
      19:03 sri             like t/my_webservice_cache/
      19:04 stephan48       for easier collection of such a test responses?
      19:04 sri             yes
      19:04 sri             you collect the responses from the live service once
      19:04 sri             and then have a directory with cached responses you can commit
      19:04 sri             and when you add something new you run it again and have a new file
      19:05 stephan48       sounds like a good idea. i can imagine this being a hudge benefit. cause who isn't lazy and skips thoose "live server" tests because they either don't wann have their tests poke a live server or don't wanna bother with manually collecting and replaying such "recordings".
      19:05 sri             or just delete all cached files to get fresh data
      19:06 stephan48       wasn't there a plugin for the useragent doing something similar(transaction replaying)?
      19:06 sri             this came up at work when coolo had to modify one of my tests and add more responses to the mock web service
      19:07 sri             yea, but i think it's not done correctly
      19:08 sri             think you mean this https://metacpan.org/pod/Mojo::UserAgent::Mockable
      19:08 sri             it's very different
      19:08 sri             not even close actually
      19:09 sri             what i have in mind would be a proxy app you can add to any Mojo::UserAgent instance
      19:11 stephan48       as a seperate http/unix-socks proxy?
      19:11 sri             no
      19:12 sri             $ua->server->app(Mojo::CachingTestProxy->new)
      19:12 sri             or rather
      19:12 sri             $ua->server->app(Mojo::CachingTestProxy->new('t/my_webservice_cache'))
      19:12 sri             or even
      19:13 sri             $ua->server->app(Mojo::CachingTestProxy->new('http://my.webservice.example.com/lalalala', 't/my_webservice_cache'))
      19:14 sri             $ua->get('/weather?city=berlin');
      19:14 sri             that would request http://my.webservice.example.com/lalalala/weather?city=berlin and cache the response in t/my_webservice_cache for the next time that same request is sent
      19:15 stephan48       yup
      19:15 sri             personally i don't care very much about headers yet, but if anyone wants to turn it into an ongoing project, add support for interesting headers one by one
      19:16 sri             and if you need to support like $us->get('http://example.com/weather?city=berlin'), just have an example for how to add a start event to rewrite the url
      19:17 sri             s/us/ua/
      19:18 sri             would have been an interesting hackweek project too
      19:18 sri             but came up a little late
      19:18 sri             maybe in 8 months ;p
      19:18 sri             unless someone beats me to it
    
Clone this wiki locally