Skip to content

Blueprint Cheat Sheet

Al Beebe edited this page Nov 2, 2015 · 54 revisions
Microservices
Client

Microservice that doesn't send a response

microservice {

  description "Create a widget"
  uri "microservice:///example/v1/create/widget"

}

Microservice that sends a single response

microservice {

  description "Get a widget"
  uri "microservice:///example/v1/get/widget"

  response {
    description "Successfully received a widget back"
    uri "resource:///example/reply/widget-instance"
  }

}

Microservice that can send more then one response

microservice {

  description "Get a widget"
  uri "microservice:///example/v1/get/widget"

  response {
    description "Successfully received a widget back"
    uri "resource:///example/reply/widget-instance"
  }

  response {
    description "Failed to get a widget"
    uri "resource:///example/reply/error"
  }

}

Microservice that can receive sub requests

microservice {

  description "Get a widget"
  uri "microservice:///example/v1/get/widget"

  response {
    description "Successfully received a widget back"
    uri "resource:///example/reply/widget-instance"
  }

  response {
    description "Failed to get a widget"
    uri "resource:///example/reply/error"
  }

  request {
    description "Abort getting the original widget and get a different one"
    uri "resource:///example/get/widget"
  }

}

Override the context and payload the client sends to the microservice

microservice {

  description "Get a widget"
  uri "microservice:///example/v1/get/widget"
  context {
    package "example"
    object "new-context"
  }
  payload {
    package "example"
    object "widget-lookup"
  }

  response {
    description "Successfully received a widget back"
    uri "resource:///example/reply/widget-instance"
  }

  response {
    description "Failed to get a widget"
    uri "resource:///example/reply/error"
  }

}

Override the context and payload the microservice returns to the client

microservice {

  description "Get a widget"
  uri "microservice:///example/v1/get/widget"

  response {
    description "Successfully received a widget back"
    uri "resource:///example/reply/widget"
    context {
      package "example"
      object "new-context"
    }
    payload {
      package "example"
      object "widget-instance"
    }
  }

  response {
    description "Failed to get a widget"
    uri "resource:///example/reply/error"
  }

}

Adding documentation to explain how the microservice works

microservice {

  description "Get a widget"
  uri "microservice:///example/v1/get/widget"

  documentation "Getting a widget is fairly straightforward.
                 Just send an Example.Widget object and we'll return
                 an Example.WidgetInstance if the widget exists.
                 If for whatever reason the widget cannot be returned,
                 we'll send you an Example.Error object"

  response {
    description "Successfully received a widget back"
    uri "resource:///example/reply/widget-instance"
  }

  response {
    description "Failed to get a widget"
    uri "resource:///example/reply/error"
  }

}

Client request that doesn't return a response

client {

  description "A new widget was received"
  uri "client:///example/v1/new/widget"

}

Client request that returns a single response

client {

  description "A new widget was received"
  uri "client:///example/v1/new/widget"

  response {
    description "Confirm the widget was received"
    uri "resource:///example/received/widget"
  }

}

Client request that can send more then one response

client {

  description "A new widget was received"
  uri "client:///example/v1/new/widget"

  response {
    description "Confirm the widget was received"
    uri "resource:///example/received/widget"
  }

  response {
    description "Reply with an error"
    uri "resource:///example/reply/error"
  }

}

Client request that can receive sub requests

client {

  description "A new widget was received"
  uri "client:///example/v1/new/widget"

  response {
    description "Confirm the widget was kissed"
    uri "resource:///example/kissed/widget"
  }

  response {
    description "Confirm the widget was received"
    uri "resource:///example/received/widget"
  }

  response {
    description "Reply with an error"
    uri "resource:///example/reply/error"
  }

  request {
    description "Kiss the widget that was just received"
    uri "resource:///example/kiss/widget"
  }

}

Override the context and payload the microservice sends to the client

client {

  description "A new widget was received"
  uri "client:///example/v1/new/widget"
  context {
    package "example"
    object "new-context"
  }
  payload {
    package "example"
    object "widget-instance"
  }

  response {
    description "Confirm the widget was received"
    uri "resource:///example/received/widget"
  }

  response {
    description "Reply with an error"
    uri "resource:///example/reply/error"
  }

}

Override the context and payload the client returns to the microservice

client {

  description "A new widget was received"
  uri "client:///example/v1/new/widget"

  response {
    description "Confirm the widget was received"
    uri "resource:///example/received/widget"
    context {
      package "example"
      object "new-context"
    }
    payload {
      package "example"
      object "generic-success"
    }
  }

  response {
    description "Reply with an error"
    uri "resource:///example/reply/error"
  }

}

Adding documentation to explain how the request works

client {

  description "A new widget was received"
  uri "client:///example/v1/new/widget"

  documentation "From time to time, new widgets pop into existance.
                 Whenever this happens, this is how you are notified.
                 You should save the widget and then confirm you
                 received the widget."

  response {
    description "Confirm the widget was received"
    uri "resource:///example/received/widget"
  }

  response {
    description "Reply with an error"
    uri "resource:///example/reply/error"
  }

}
Clone this wiki locally