apparatus / fuge

The microservice shell
http://fuge.io
MIT License
432 stars 49 forks source link

idea: rapidly create throwaway mock-services from command line #15

Open davidmarkclements opened 8 years ago

davidmarkclements commented 8 years ago

in shell:

fuge> mock my-mock-service
Pattern: {'role': 'service-to-be-done-later', cmd: 'uwatm8'}
Response:
   {
      res: 'ok', 
      nahnah: true
   }
Ctrl^D
Pattern: Ctrl^D
creating mock service
starting mock service
fuge> ps
name                         type            status          watch           tail            count
mongo                        docker          not managed
apache                       docker          not managed
service1                     process         started         yes             yes             1
my-mock-service              mocked          started         n/a             yes             1 

Pattern: and Response: are prompts, the data that comes after is user supplied

The idea is it's framework independent - simply define pattern and response

There's a few angles here

1) create a temporary service that disappears when the shell closes 2) as 1, except don't disappear, save it somewhere internally (not as a generated seneca service) 3) possibly create a way to "commit" or "convert" a mock service into a full generated service, building boilerplate around supplied pattern-responses 4) add/remove/edit pattern-responses for a mock-service

mcollina commented 8 years ago

How can you make it non-specific to seneca? You still want to mess with transports...

davidmarkclements commented 8 years ago

I don't think we'd need to in this scenario - the idea is we're stubbing out something in the system while we build other parts.

If we assume point to point - fuge proxy can take it from there

Whether you're using seneca or not, regardless of transport for other services, you know you're talking to a mock service over http req/res. so with seneca it would be a simple seneca.listen and no args, for anything else it would be some http lib or what not. Once you build that service you choose to set the transport (e.g. add a beanstalk arg to seneca, or whatever way you'd do it without seneca)

davidmarkclements commented 8 years ago

just to add - the underlying code that creates the mock service could (and probably should) be seneca - the point is that shouldn't matter to the overall system

pelger commented 8 years ago

Interesting - definitely worth a ponder...

davidmarkclements commented 8 years ago

just noting micro by @rauchg here as an example of alt. micro-service approach that could/should/would be compatible with fuge

mcdonnelldean commented 8 years ago

@davidmarkclements @mcollina @pelger

I just want to flag that in using fuge in anger I am starting to think the generation stuff should be pulled out into another module. It's not that I don't use it (in fact I intend to build some generators) but I'm just worried it might be doing too much.

Sorry to butt in here, it seemed like a good place to flag.

mcollina commented 8 years ago

I'm completely with you @davidmarkclements

davidmarkclements commented 8 years ago

@mcollina - yay

@mcdonnelldean - have had a few related convos with @pelger about this - but let's discuss elsewhere (possibly new issue)

mcdonnelldean commented 8 years ago

@davidmarkclements Agreed. On this issue, (mocks) yay from me! Love the idea of being able to do this for fast prototyping. +1 from me

AdrianRossouw commented 8 years ago

what's the difference between using a scaffold to pop up a test service, and then not committing it. versus this kind of inline mock.

you could even add them to the .gitignore if you really don't want them to be persisted.

AdrianRossouw commented 8 years ago

@mcdonnelldean @davidmarkclements - we need our own scaffolding tool

davidmarkclements commented 8 years ago

@AdrianRossouw agreed