Comments (3)
This idea was proposed by a few stakeholders in another forum. Moving it here for the OS community:
A. The component author is expected to export two functions when he wants to handle the diffing by himself (that’s what we currently have in place):
deploy
- this function creates and updates the required infra based on the state. The component author writes the diffing logic himselfremove
- this function removes the entire infra, based on the state
B. When the component author wants to let the framework handle input diffing, he is expected to export three alternative functions:
create
- this function creates the required infra from scratchupdate
- this function updates the required infra without teardowndelete
- this function deletes the entire infra
Then in his serverless.yml
, the component author specifies which inputs trigger a teardown
when changed, and which just runs an update. Something like this:
name:
teardown: true # changing the lambda name for example requires deleting + creating from scratch
memory:
teardown: false # changing the memory should just update
The framework then checks what inputs have changed by comparing to the saved inputs from the previous state, and can determine the right action based on this teardown
property (update
or delete + create
). Although this is now harder to do since the introduction of saveState()
, because we can’t guarantee that the previous inputs have been saved to state. So the component author either needs to save the inputs to state himself, or the framework could automatically do that.
That’s basically it at a high level! I noticed that most providers/infra can follow this pattern. With this implementation, component authors don’t need to have all those state specific if statements in the deploy function in most cases. When this is not flexible enough for them, they can revert to the deploy + remove
pair instead.
from components.
Interesting idea. Here is my feedback:
I don't see how the Create, Update, Delete (CUD) would work for my main use-case. I am building higher-order components that dynamically set up specific children components (e.g. the Function or Subscription component) based on config given, and the Framework cannot make CUD decisions for the higher-order component because it uses dynamic infra components as children, which all need to be treated differently. This leads me to believe many component implementations cannot use the CUD approach.
How would this work for components that manage multiple resources? For example, AWS API Gateway creates many resources when you create your API. However, component authors aren't going to want to create tons of separate Components for all of the resources API Gateway needs. At the same time, when building it as one large Component, the REST API should not be torn down if an endpoint is changed, so the Component author will end up writing removal syntax in the update method anyway.
Also, all of my components have object type configuration syntax. I would not be able to use this until it supports deeply nested configuration.
How would this work with configuration arrays? When implementing diff logic in POC #242, arrays turned out to be quite tricky.
Offering duplicate ways to do something so fundamental (both deploy
+ remove
AND create
+ update
+ delete
) will create a ton of complexity, IMO. Architecture + docs + examples + tutorials + extensibility will all echo this added complexity and it will cause a general decline in DX.
I believe we should wait and learn more before considering the above suggestion. Overall, my components' logic is growing in sophistication as I optimize for speed and reliability. Yet, the above proposal seems like an oversimplification of how to handle resources. I don't think I'd use it 95% of the time. Code is the best way to handle sophistication. The un-opinionated deploy
method allows the component author freedom to do what they feel needs to be done. Offering simple diff
info would aides that freedom. Forcing them to handle resources a specific way limits that freedom.
from components.
Created a POC for diff'ing functionality which can be found here: #242
from components.
Related Issues (20)
- Question: Is there a way to exclude @serverless/platform-client-china package? HOT 3
- Getting strange error: 28s › Serverless › There's a problem with your files and they could not be loaded by this Component. Original error: Response code 403 (Forbidden) HOT 1
- alternative cloudfront domains wiped on each deploy HOT 2
- README "Components List" doesn't link to a list of serverless-components
- How to run a different hook command for each stage?
- serverless remove doesn't work HOT 1
- commercial promotion and China user indentify code snippet HOT 3
- Dependency analysing doesn't support square brackets in output reference expression
- CLI was failing silently when there is configuration issues
- Is it possible to "serverless dev" but not auto deploy?
- Is this deprecated? HOT 15
- Error when deploy on Bitbucket
- change node version HOT 2
- Migrate from `traverse` to `neotraverse`
- Setting custom parameters for a component in serverless.yml HOT 1
- Move @serverless/platform-client-china to peerDependency HOT 2
- [feat] devOps friendly output format (JSON, YAML) HOT 6
- TLS connection error in proxy mode network
- Request timed out after 60 seconds HOT 1
- Can't install serverless-components
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from components.