R: rename runtimecontext to cfcontext

This commit is contained in:
aki-0421 2024-01-17 17:19:04 +09:00
parent cd485f7d74
commit bac0abd44b
No known key found for this signature in database
GPG Key ID: 64A8CF6D437D166A
4 changed files with 4 additions and 8 deletions

View File

@ -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

View File

@ -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

View File

@ -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{

View File

@ -1,4 +1,4 @@
package runtimecontext
package cfcontext
import (
"context"