-
Notifications
You must be signed in to change notification settings - Fork 252
/
compatibility-date.h
54 lines (43 loc) · 2.41 KB
/
compatibility-date.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
// Copyright (c) 2017-2022 Cloudflare, Inc.
// Licensed under the Apache 2.0 license found in the LICENSE file or at:
// https://opensource.org/licenses/Apache-2.0
#pragma once
#include <workerd/io/compatibility-date.capnp.h>
#include <workerd/io/worker.h>
namespace workerd {
enum class CompatibilityDateValidation {
CODE_VERSION,
// Allow dates up through the date specified by `supportedCompatibilityDate` in
// `compatiility-date.capnp`.
CODE_VERSION_EXPERIMENTAL,
// Like CODE_VERSION but permit the use of experimental flags, which is any flag that does not
// yet have a default-on date set.
CURRENT_DATE_FOR_CLOUDFLARE,
// Allow dates up to through the current date.
//
// This should ONLY be used by Cloudflare. If Cloudflare fails to deploy a compatibility flag
// before its default-on date passes, then the flag's default-on date needs to be pushed back.
//
// TODO(someday): We may want to consider eliminating this and using CODE_VERSION even for
// Cloudflare. Once people are testing their code using the open source runtime in wrangler,
// they will be forced to set a date no later than `supportedCompatibilityDate` anyway. If
// we make sure Cloudflare is updated before the runtime used locally by Wrangler is updated,
// then there's no real need for Cloudflare to accept newer dates. This would then allow us
// to avoid the situation where a release misses the deadline implied by its compat flag
// default-on dates.
FUTURE_FOR_TEST
// Allow any future date. This should only be used to test `compileCompatibilityFlags` itself.
};
void compileCompatibilityFlags(kj::StringPtr compatDate, capnp::List<capnp::Text>::Reader compatFlags,
CompatibilityFlags::Builder output,
Worker::ValidationErrorReporter& errorReporter,
CompatibilityDateValidation dateValidation);
kj::Array<kj::StringPtr> decompileCompatibilityFlagsForFl(CompatibilityFlags::Reader input);
// Return an array of compatibility enable-flags which express the given FeatureFlags. The returned
// StringPtrs point to FeatureFlags annotation parameters, which live in static storage.
//
// TODO(soon): Introduce a codec which can minimize the number of flags generated by choosing a good
// compatibility date.
kj::Maybe<kj::String> normalizeCompatDate(kj::StringPtr date);
// Exposed to unit test the parser.
} // namespace workerd