Creating a quick microservice Pub

The fastest way to create a micro-service is to define a mock for a Message:

$mock first.service (name ?= "Harry") => (greeting="Hello "+name)

Which, unescaped, looks like this:

0 $mock:: first.service (name)
   . (greeting=("Hello " + name))

Done! As soon as you save the edited topic, you can invoke it like:

diesel/wiki/specs.Topic:Creating_a_quick_microservice/react/first/service?name=Jane

And receive a JSON result (note the value for "greeting" and ignore the errors for now):

{"values":{"greeting":"Hello Jane"},"failureCount":"0","errors":["Can't find the spec for first.service"]}

Or get just the resulting value:

diesel/wiki/specs.Topic:Creating_a_quick_microservice/react/first/service?name=Jane&resultMode=value

And receive the resulting value:

Hello Jane

Note the reference to the current topic in the URL specs.Topic:Creating_a_quick_microservice.

How's that for simple ?

Fiddle with this right now

Go on, try it yourself: click this fiddle now and change the "Hello " to "Hi " and then just re-run the REST call (or click again on this link).

There's only one catch: when changing your fiddle, to see the result, you'll need to use the SketchMode++ so use this URL to call the fiddle:

diesel/wiki/specs.Topic:Creating_a_quick_microservice/react/first/service?name=Jane&resultMode=value&sketchMode=true

Remember that you can't save in this website - you'll need to create a new reactor from the main page if you want to create some proper stories!


Was this useful?    

By: Razie | 2016-06-22 .. 2017-05-01 | Tags: academy , dsl


Viewed 180 times ( | Print ) this page.

You need to log in to post a comment!

© Copyright DieselApps, 2012-2021, all rights reserved.