-
-
Notifications
You must be signed in to change notification settings - Fork 1
Initial scheduler working prototype #1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -5,6 +5,7 @@ export 'src/functions/common/options.dart'; | |||||
export 'src/functions/v2/providers/firestore.dart'; | ||||||
export 'src/functions/v2/providers/https.dart'; | ||||||
export 'src/functions/v2/providers/identity.dart'; | ||||||
export 'src/functions/v2/providers/scheduler.dart'; | ||||||
export 'src/functions/v2/core.dart'; | ||||||
|
||||||
/// Access to Firebase Functions components | ||||||
|
@@ -22,4 +23,8 @@ abstract final class FirebaseFunctions { | |||||
/// Access to the Firebase Functions Identity methods | ||||||
static FirebaseFunctionsIdentity get identity => | ||||||
require('firebase-functions/v2/identity') as FirebaseFunctionsIdentity; | ||||||
|
||||||
/// Access to the Firebase Functions Schedule methods | ||||||
static FirebaseFunctionsSchedule get schedule => | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
require('firebase-functions/v2/scheduler') as FirebaseFunctionsSchedule; | ||||||
} |
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
@@ -0,0 +1,100 @@ | ||||||
// The MIT License (MIT) | ||||||
// | ||||||
// Copyright (c) 2022 Firebase | ||||||
// | ||||||
// Permission is hereby granted, free of charge, to any person obtaining a copy | ||||||
// of this software and associated documentation files (the "Software"), to deal | ||||||
// in the Software without restriction, including without limitation the rights | ||||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||||||
// copies of the Software, and to permit persons to whom the Software is | ||||||
// furnished to do so, subject to the following conditions: | ||||||
// | ||||||
// The above copyright notice and this permission notice shall be included in all | ||||||
// copies or substantial portions of the Software. | ||||||
// | ||||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||||||
// SOFTWARE. | ||||||
|
||||||
import 'dart:js_interop'; | ||||||
|
||||||
export 'package:firebase_js_interop/src/functions/common/providers/https.dart'; | ||||||
|
||||||
/// Options that can be set on a schedule function. | ||||||
extension type ScheduleOptions._(JSObject _) implements JSObject { | ||||||
/// The schedule in Unix Crontab or AppEngine syntax. | ||||||
external JSAny? get schedule; | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
|
||||||
/// The timezone that the schedule executes in. | ||||||
external JSAny? get timeZone; | ||||||
|
||||||
/// The number of retry attempts for a failed run. | ||||||
external JSAny? get retryCount; | ||||||
|
||||||
/// The time limit for retrying. | ||||||
external JSAny? get maxRetrySeconds; | ||||||
|
||||||
/// The minimum time to wait before retrying. | ||||||
external JSAny? get minBackoffSeconds; | ||||||
|
||||||
/// The maximum time to wait before retrying. | ||||||
external JSAny? get maxBackoffSeconds; | ||||||
|
||||||
/// The time between retries will double maxDoublings times. | ||||||
external JSAny? get maxDoublings; | ||||||
|
||||||
/// Constructor | ||||||
external ScheduleOptions({ | ||||||
JSAny? schedule, | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
JSAny? timeZone, | ||||||
JSAny? retryCount, | ||||||
JSAny? maxRetrySeconds, | ||||||
JSAny? minBackoffSeconds, | ||||||
JSAny? maxBackoffSeconds, | ||||||
JSAny? maxDoublings, | ||||||
}); | ||||||
} | ||||||
|
||||||
/// Event passed to a scheduled function handler. | ||||||
extension type ScheduledEvent._(JSObject _) implements JSObject { | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This should be above |
||||||
/// The Cloud Scheduler job name. | ||||||
external String? get jobName; | ||||||
|
||||||
/// The schedule time in RFC3339 UTC "Zulu" format. | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This doc string does not match the source. All doc strings need checked for this since ChatGPT generated this. |
||||||
external String get scheduleTime; | ||||||
|
||||||
/// Constructor | ||||||
external ScheduledEvent({ | ||||||
String? jobName, | ||||||
String? scheduleTime, | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
}); | ||||||
} | ||||||
|
||||||
/// The Cloud Function type for Schedule triggers. | ||||||
extension type ScheduleFunction._(JSObject _) implements JSObject { | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This type declaration is unnecessary since Dart doesn't need to do anything with it |
||||||
external JSObject get requiredAPIs; | ||||||
external JSFunction run(ScheduledEvent event); | ||||||
|
||||||
/// Constructor | ||||||
external ScheduleFunction({ | ||||||
JSObject requiredAPIs, | ||||||
JSFunction? run, | ||||||
}); | ||||||
} | ||||||
|
||||||
/// The Firebase Functions Schedule namespace | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
extension type FirebaseFunctionsSchedule._(JSObject _) implements JSObject { | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
/// Handles scheduled function invocations. | ||||||
/// @param options - Options to set on the schedule function | ||||||
/// @param handler - A function to execute when triggered | ||||||
/// @returns A function that you can export and deploy | ||||||
external JSFunction onSchedule( | ||||||
JSObject optionsOrSchedule, [ | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
JSObject does not include primitives |
||||||
// (ScheduledEvent event) => FutureOr<void> | ||||||
JSFunction handler, | ||||||
]); | ||||||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.