mirror of
https://github.com/syumai/workers.git
synced 2025-03-10 17:29:11 +00:00
R: rename runtimecontext to cfcontext
This commit is contained in:
parent
cd485f7d74
commit
bac0abd44b
@ -8,7 +8,6 @@ import (
|
||||
"time"
|
||||
|
||||
"github.com/syumai/workers/internal/jsutil"
|
||||
"github.com/syumai/workers/internal/runtimecontext"
|
||||
)
|
||||
|
||||
// Event represents information about the Cron that invoked this worker.
|
||||
@ -42,7 +41,7 @@ func ScheduleTask(task Task) {
|
||||
}
|
||||
|
||||
func runScheduler(eventObj js.Value, runtimeCtxObj js.Value) error {
|
||||
ctx := runtimecontext.New(context.Background(), runtimeCtxObj)
|
||||
ctx := cfcontext.New(context.Background(), runtimeCtxObj)
|
||||
event, err := toEvent(eventObj)
|
||||
if err != nil {
|
||||
return err
|
||||
|
@ -4,8 +4,6 @@ import (
|
||||
"context"
|
||||
"errors"
|
||||
"syscall/js"
|
||||
|
||||
"github.com/syumai/workers/internal/runtimecontext"
|
||||
)
|
||||
|
||||
/**
|
||||
@ -49,7 +47,7 @@ var ErrValueNotFound = errors.New("execution context value for specified key not
|
||||
// GetRuntimeContextValue gets value for specified key from RuntimeContext.
|
||||
// - if the value is undefined, return error.
|
||||
func GetRuntimeContextValue(ctx context.Context, key string) (js.Value, error) {
|
||||
runtimeCtxValue := runtimecontext.MustExtract(ctx)
|
||||
runtimeCtxValue := cfcontext.MustExtract(ctx)
|
||||
v := runtimeCtxValue.Get(key)
|
||||
if v.IsUndefined() {
|
||||
return js.Value{}, ErrValueNotFound
|
||||
|
@ -9,7 +9,6 @@ import (
|
||||
|
||||
"github.com/syumai/workers/internal/jshttp"
|
||||
"github.com/syumai/workers/internal/jsutil"
|
||||
"github.com/syumai/workers/internal/runtimecontext"
|
||||
)
|
||||
|
||||
var httpHandler http.Handler
|
||||
@ -49,7 +48,7 @@ func handleRequest(reqObj js.Value, runtimeCtxObj js.Value) (js.Value, error) {
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
ctx := runtimecontext.New(context.Background(), runtimeCtxObj)
|
||||
ctx := cfcontext.New(context.Background(), runtimeCtxObj)
|
||||
req = req.WithContext(ctx)
|
||||
reader, writer := io.Pipe()
|
||||
w := &jshttp.ResponseWriter{
|
||||
|
@ -1,4 +1,4 @@
|
||||
package runtimecontext
|
||||
package cfcontext
|
||||
|
||||
import (
|
||||
"context"
|
Loading…
x
Reference in New Issue
Block a user