|
44 | 44 | - Won’t clash with existing values
|
45 | 45 | - *e.g. UUID (RFC 4122)*
|
46 | 46 | - *e.g. SHA256 hash digest (RFC 6234)*
|
47 |
| -- Could still be guessable: *e.g. Auto increment SQL primary key* |
| 47 | +- Warning: could still be [guessable](#guessable): *e.g. Auto increment SQL primary key* |
48 | 48 |
|
49 | 49 | ```console
|
50 | 50 | # UUID
|
|
59 | 59 | - *e.g. UUID v4*
|
60 | 60 | - *e.g. Cryptographically Random source*
|
61 | 61 |
|
62 |
| -<h3 id=guessable>Guessable</h3> |
| 62 | +```console |
| 63 | +> head -c16 /dev/urandom | base64 |
| 64 | +4mQ9EA== |
| 65 | +``` |
| 66 | + |
| 67 | +<h3 id=guessable>Undesirable: Guessable</h3> |
63 | 68 |
|
64 | 69 | - Not Secure
|
65 | 70 | - Not [Random](#random)
|
66 |
| -- *e.g. Auto increment SQL primary key* |
| 71 | +- *e.g. Auto incrementing SQL primary key* |
| 72 | +- *e.g. The current time* |
| 73 | + |
| 74 | +```console |
| 75 | +> date -u '+%Y-%m-%dT%H:%M:%SZ' |
| 76 | +2021-02-07T22:51:21Z |
| 77 | +``` |
67 | 78 |
|
68 | 79 | ----
|
69 | 80 |
|
70 | 81 | <h2>Acts</h2>
|
71 | 82 |
|
72 | 83 | <h3 id=immutable>Immutable</h3>
|
73 | 84 |
|
74 |
| -- Benefits caching |
75 |
| -- Benefits syncing |
76 |
| -- *e.g. Twitter tweets are not editable* |
77 |
| -- *e.g. a Git commit* |
78 |
| -- *e.g. a YouTube video cannot be edited* |
| 85 | +- Changes to data work on a copy, preserving the original |
| 86 | +- Benefits caching: *given I have an object’s ID, the contents will always be the same* |
| 87 | +- Benefits syncing: *retrieve only the parts I do not yet have* |
| 88 | +- *e.g. Twitter tweets cannot be edited, only deleted* |
| 89 | +- *e.g. YouTube video media cannot be edited, only deleted* |
| 90 | +- *e.g. Git object from a committed file* |
79 | 91 |
|
80 | 92 | <h3 id=stateless>Stateless</h3>
|
81 | 93 |
|
|
84 | 96 |
|
85 | 97 | <h3 id=idempotent>Idempotent</h3>
|
86 | 98 |
|
87 |
| -- *e.g. At-least-once event delivery* |
88 |
| -- Could use Random identifier in request to record which commands have already been completed |
| 99 | +- The same effect is produced if run once, twice, or a thousand times |
| 100 | +- *e.g. Consumer of an at-least-once event delivery system* |
| 101 | +- *e.g. [Stripe charges](https://stripe.com/docs/api/idempotent_requests)* |
| 102 | +- Hint: Could generate a [random](#random) identifier for each request, which allows recording which commands have already been processed. |
89 | 103 |
|
90 | 104 | <h3 id=versioned>Versioned</h3>
|
91 | 105 |
|
|
0 commit comments