Skip to content

Commit

Permalink
Merge pull request #22 from stakater/how-to-model-workflows-in-rest-apis
Browse files Browse the repository at this point in the history
How to model workflows in rest apis
  • Loading branch information
kahootali authored Feb 7, 2019
2 parents 181bee7 + fe37665 commit 94a2d8d
Show file tree
Hide file tree
Showing 5 changed files with 43 additions and 0 deletions.
28 changes: 28 additions & 0 deletions api/how-to-model-workflows-in-rest-apis.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# How to Model Workflows in REST APIs?

RESTful Web Services are awesome for performing basic CRUD operations on database tables, but they get even more exciting when you realize that they can also be used for modeling workflows and other advanced stuff.

There are three options:

1. Use an Attribute for the Workflow’s State
2. Use Hyperlinks for Workflow Transitions
3. Use a Subresource for Workflow Transitions

## So which one should I pick?

So we came to the unavoidable question: What approach is the best one?

As always, it depends on the context, but here are some quick guidelines:

| Approach | When |
| --- | --- |
| State Attribute | When there are no restrictions on the transitions. You can go from any state to any state at any time. The states are basically nothing more than a list of values. |
| Transition Links | There are limits to which states you can go to depending on the current state. |
| Transition Subresource | The workflow is configurable by users, so states and transitions among them are not fixed, but can be changed at runtime. |


## Reference

Read following for more details:

- https://www.kennethlange.com/how-to-model-workflows-in-rest-apis/
1 change: 1 addition & 0 deletions architecture/object-calisthenics.md
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,7 @@ What’s challenging about creating such small classes is that there are often g

## 8. Do Not Use Classes With More Than Two Instance Variables

**TODO**

## 9. Do not Use Getters and Setters

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@ spec:
labels:
{{ toYaml .Values.handbook.deployment.podLabels | indent 8 }}
spec:
{{- if .Values.handbook.deployment.tolerations }}
tolerations:
{{ toYaml .Values.handbook.deployment.tolerations | indent 8 -}}
{{- end }}
imagePullSecrets:
- name: {{ .Values.handbook.deployment.imagePullSecrets }}
containers:
Expand Down
5 changes: 5 additions & 0 deletions deployments/kubernetes/chart/developer-handbook/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,11 @@ handbook:
labels:
expose: 'true'
deployment:
tolerations:
- key: "dedicated"
operator: "Equal"
value: "app"
effect: "NoSchedule"
replicas: 1
podLabels:
app: developer-handbook
Expand Down
5 changes: 5 additions & 0 deletions deployments/kubernetes/templates/chart/values.yaml.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,11 @@ handbook:
labels:
expose: 'true'
deployment:
tolerations:
- key: "dedicated"
operator: "Equal"
value: "app"
effect: "NoSchedule"
replicas: 1
podLabels:
app: developer-handbook
Expand Down

0 comments on commit 94a2d8d

Please sign in to comment.