Replies: 2 comments 4 replies
-
Thanks @pgarbe, let me try to turn this into a code example To implement the above example we need 2 types of resources:
To match @pgarbe example, lets assume that Here is wing code bring cloud;
bring some_external_translate; //This translate is only implemented for AWS
let origin_bucket = new cloud.Bucket() as "origin"
let translated_bucket = new cloud.Bucket() as "translated"
let translator = new some_external_translate.Translator();
origin.on_update(((key: str) ~> {
let content = origin_bucket.get(key);
let translated = translator.translate(content);
translated_bucket.put(key, translated);
})) Because wing compile <file>
ERROR: no "sim" target for some_external_translate.Translator As the owner of this NPM package, not providing a sim solution is a very bad experience for the package consumers. This is quite simple, all that is needed to implement is a Here is a naive implementation: export class Translator implements ITranslatorClient, ISimulatorResourceInstance {
private readonly context: ISimulatorContext;
public constructor(
context: ISimulatorContext
) {
this.context = context;
}
public async init(): Promise<void> {}
public async cleanup(): Promise<void> {}
public async translate(content: string): Promise<string> {
return content.toLocaleUpperCase();
}
} Now the developer of this application can compile this only for aws and sim, but it might be good enough for the business need of the app. Eventually there will be a couple of external @pgarbe does this help? |
Beta Was this translation helpful? Give feedback.
-
Thanks @ekeren for that detailed explanation. That makes sense to me. I guess the challenge comes with deciding what is part of the core library and what not. What's your idea or process on defining what should be part of the core library? I've seen Endpoint in the backlog. Straight forward from the perspective of an application developer. But I'm curious about the implementation. There are many possibilities how that could translate into AWS. |
Beta Was this translation helpful? Give feedback.
-
Wing is still elusive to me. I understood that there are so called resources which can be a real cloud resource (e.g. Bucket) or more abstract (e.g. Counter). With Elad I have clarified that cross-cutting concerns, like encryption are rather located at (cloud-) specific backends.
But where I struggle is how a serverless application would look like. For example a web application to upload documents to a bucket. After the upload, the document is translated using a managed cloud service and stored in another bucket.
What could the integration look like with the frontend? The code for presigned URLs for upload might be very specific to the cloud vendor. How could I test this in the simulator?
Probably there is no “Translate” resource in Wing either (or is there?). A service like Amazon Translate is only available on AWS and not on other clouds (I guess). How would I implement this in Wing? Would it mean to write separate resources for each cloud service?
I know that Wing is in an early stage. But maybe you have some ideas how that could look like? It would help me to make the whole thing more tangible.
Beta Was this translation helpful? Give feedback.
All reactions