Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Revamp transforming message formats tutorial #8233

Conversation

dulajdilshan
Copy link
Contributor

Purpose

$title

Checklist

  • Page addition

    • Add permalink to pages.
  • Page removal

    • Remove entry from corresponding left nav YAML file.
    • Add redirect_from on the alternative page.
    • If no alternative page, add redirection on the redirections.js file.
  • Page rename

    • Add front-matter redirect_from.
    • Add front-matter redirect_to: (if applicable).
  • Page restrcuture

    • Add permalink to pages.
    • Add front-matter redirect_from.
    • Add front-matter redirect_to: (if applicable).

@mindula
Copy link
Contributor

mindula commented Nov 10, 2023

(L17) let's add a full stop.

@mindula
Copy link
Contributor

mindula commented Nov 10, 2023

(L255) The parameter name should be reservation not payload.

@mindula
Copy link
Contributor

mindula commented Nov 10, 2023

(L262-L267) We decided to remove log statements except for error logs.

@mindula
Copy link
Contributor

mindula commented Nov 10, 2023

(L60) Shall we change the appointment number to 1?

@mindula
Copy link
Contributor

mindula commented Nov 10, 2023

(L351) Should be [reservation.hospitalId]

…vamp-transform-message-formats

# Conflicts:
#	swan-lake/integration-tutorials/content-based-message-routing.md
#	swan-lake/integration-tutorials/service-orchestration.md
@mindula mindula merged commit d052e79 into ballerina-platform:integration-tutorials Nov 10, 2023
1 check passed
@dulajdilshan dulajdilshan deleted the revamp-transform-message-formats branch November 10, 2023 12:34
Import the
- `ballerina/http` module to develop the REST API and define the client that can be used to send requests to the backend services
- `ballerina/log` module to log debug, error, or info level information for each client request
3. Generate record types corresponding to the payloads from the hospital service and input/output of the transforming function by providing samples of the expected JSON payloads.
Copy link
Member

@MaryamZi MaryamZi Nov 13, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We haven't spoken about a "transforming function" before we get here, so may not make sense to the user.

I would have

  1. if there is a request payload, show generating the record for that. if not, show generating a record for the payload from the backend.
  2. if there are other request or response payloads, say "Similarly, generate records ...". Don't have to give the JSON payloads and/or show generating records here.
  3. then say "The generated record types will be as follows." for all.

So basically, show one JSON -> record generation for whatever we encounter first. And then say generate similarly for others and show the records.

> **Note:**
> When the fields of the JSON objects are expected to be exactly those specified in the sample payload, the generated records can be updated to be [closed records](https://ballerina.io/learn/by-example/controlling-openness/), which would indicate that no other fields are allowed or expected.

4. Define the [HTTP service (REST API)](https://ballerina.io/learn/by-example/#rest-service) that has the resource that accepts user requests, retrieves relevant details from the backend service, and responds to the request.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Better to include something about transforming here.


return <http:InternalServerError> {body: resp.message()};
```
- If the response is not a `ReservationResponse` record, log the information at `ERROR` level. Return a "NotFound" response if the response from the hospital service is an `http:ClientRequestError` response or an "InternalServerError" response otherwise.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fix "NotFound" -> http:NotFound.

Same for "InternalServerError".


> **Note:**
> When the fields of the JSON objects are expected to be exactly those specified in the sample payload, the generated records can be updated to be [closed records](https://ballerina.io/learn/by-example/controlling-openness/), which would indicate that no other fields are allowed or expected.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add a note about making ssn an array of fixed-length (and maybe link to a BBE).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants