The essence of an API | function
The first step in prototyping an API is to decouple the API's form from the function and design the conceptual API. Let's take the classic example of a cart service...
$msg cart.addItem (customerId, sku, quantity) : (cart)
$msg cart.get (customerId) : (cart)
di:es:el editor
dsl here...
Change the name of the message say.hi
or change the default value there, from "Harry"
to "me"
, or something.
Then hit "Save" and play with it (hint: checkout the REST tab).
Note that even though you are not logged in, you can play with this! Cool, huh?
Your temporary "session" will expire in 5 minutes or so... if you mock it up, just refresh the page to start again.
To edit this topic and fully explore this, just create an account!
Use this !
Nah
Having an API can be easy - here's one just above (one that you can edit and fiddle with). We just defined the "cart" service, with two functions/messages... we can add details like types later.
API | form
The "form" of the API is where you map the conceptual to the physical. Although you'd do this towards the end of the prototyping stage, here's a simple REST mapping of this API - if you need to present it to any upstream services:
{{template cart.addItem:request}}
POST /diesel/wreact/wiki.Admin:Home-1/react/customer/$customerId/cart/addItem?extra=$extra&resultMode=json
Content-Type : application/json
{ "sku" : "$sku", "quantity" : "$quantity" }
{{/template}}
di:es:el editor
dsl here...
Change the name of the message say.hi
or change the default value there, from "Harry"
to "me"
, or something.
Then hit "Save" and play with it (hint: checkout the REST tab).
Note that even though you are not logged in, you can play with this! Cool, huh?
Your temporary "session" will expire in 5 minutes or so... if you mock it up, just refresh the page to start again.
To edit this topic and fully explore this, just create an account!
Use this !
Nah
Mocking APIs and services
Since we now have the API specified and bound to an HTTP request, how about mocking, so we can continue developing upstream systems?
$mock cart.addItem (customerId ?= "Joe", sku ?="123", quantity ?= 5)
=> cart.get
=> (cart=cart+{items:{sku : "${sku}", quantity : "${quantity}"} })
$mock cart.get (customerId ?= "Joe") => (cart = {customerId : "Joe", items : []})
di:es:el editor
dsl here...
Change the name of the message say.hi
or change the default value there, from "Harry"
to "me"
, or something.
Then hit "Save" and play with it (hint: checkout the REST tab).
Note that even though you are not logged in, you can play with this! Cool, huh?
Your temporary "session" will expire in 5 minutes or so... if you mock it up, just refresh the page to start again.
To edit this topic and fully explore this, just create an account!
Use this !
Nah
In fact, this is also the simplest microservice you could have ever created (read more++)
Interested in accelerating microservices development ? ...
Integration and mediation
Integrating systems and composing their functionality...
$msg catalog.getPrice (sku)
$msg cart.addItem (customerId ?= "Joe", sku, quantity)
$msg billing.charge (customerId >= "Joe", amount)
di:es:el editor
dsl here...
Change the name of the message say.hi
or change the default value there, from "Harry"
to "me"
, or something.
Then hit "Save" and play with it (hint: checkout the REST tab).
Note that even though you are not logged in, you can play with this! Cool, huh?
Your temporary "session" will expire in 5 minutes or so... if you mock it up, just refresh the page to start again.
To edit this topic and fully explore this, just create an account!
Use this !
Nah
APIs are often much less interesting than the stories they tell... or the stories you can create with them, i.e. systems, apps etc. The behaviour of these systems as a whole... that's where the value of the system is.
Testing microservices
$send say.hi (name = "Jane")
$expect (greeting contains "Jane")
di:es:el editor
dsl here...
Change the name of the message say.hi
or change the default value there, from "Harry"
to "me"
, or something.
Then hit "Save" and play with it (hint: checkout the REST tab).
Note that even though you are not logged in, you can play with this! Cool, huh?
Your temporary "session" will expire in 5 minutes or so... if you mock it up, just refresh the page to start again.
To edit this topic and fully explore this, just create an account!
Use this !
Nah
How do we specify our expectations about the value? How do we communicate it,
record it, share it, cooperate on it?
Use cases and user stories can turn into automated tests! (one that you can run and trace right now) (read more++)
Interested in simplifying microservices testing? ...
In the modern age, enterprises are transformed by microservices, APIs and reactive principles.
If you want to take a refreshing look at microservices requirements, acceptance and truly continuous testing, while fiddling with the architecture itself, start by creating a free account.
Used by companies like...
Was this useful?
Thank you!
By:
Razie
|
2019-08-25
.. 2020-11-28
| Tags:
admin