appengine

package
v1.2.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 8, 2020 License: MIT Imports: 15 Imported by: 3

Documentation

Index

Constants

View Source
const (

	// AppEngineTaskName Header Key
	AppEngineTaskName = "X-AppEngine-TaskName"

	// AppEngineQueueName Header Key
	AppEngineQueueName = "X-AppEngine-QueueName"

	// AppEngineTaskRetryCount Header Key
	AppEngineTaskRetryCount = "X-AppEngine-TaskRetryCount"

	// AppEngineTaskExecutionCount Header Key
	AppEngineTaskExecutionCount = "X-AppEngine-TaskExecutionCount"

	// AppEngineTaskETA Header Key
	AppEngineTaskETA = "X-AppEngine-TaskETA"

	// AppEngineTaskPreviousResponse Header Key
	AppEngineTaskPreviousResponse = "X-AppEngine-TaskPreviousResponse"

	// AppEngineTaskRetryReason Header Key
	AppEngineTaskRetryReason = "X-AppEngine-TaskRetryReason"

	// AppEngineFailFast Header Key
	AppEngineFailFast = "X-AppEngine-FailFast"

	// GoogleInternalSkipAdminCheck Header Key
	GoogleInternalSkipAdminCheck = "X-Google-Internal-Skipadmincheck"
)

Variables

View Source
var ErrNotFoundHeader = errors.New("not found cloudtasks header")

ErrNotFoundHeader is Cloud Tasks の Headerがない時に利用されます。

Functions

func ValidateJWTFromHttpTargetTask added in v1.1.0

func ValidateJWTFromHttpTargetTask(ctx context.Context, r *http.Request, projectNumber string, projectID string) (*auth.JWTPayload, error)

ValidateJWTFromHttpTargetTask is Http Target Task を App Engine で受けた時の JWT の検証を行う App Engine Task の場合は JWT はくっついていないので、 auth.IsGCPInternal() をチェックすることになる

Types

type GetTask

type GetTask struct {

	// Task を Unique にしたい場合に設定する ID
	//
	// optional
	// 中で projects/PROJECT_ID/locations/LOCATION_ID/queues/QUEUE_ID/tasks/TASK_ID 形式に設定するので、TASK_ID の部分を設定する
	Name string

	// Task を到達させる App Engine の Service/Version
	// 設定しない場合は Queue の設定に従う
	// optional
	Routing *Routing

	// 任意の HTTP Request Header
	// optional
	Headers map[string]string

	// Task を到達させる path
	// "/" で始まる必要がある
	RelativeUri string

	// Task を実行する時刻
	// optional 省略した場合は即時実行
	ScheduleTime time.Time

	// Worker で Task を実行する Deadline
	// optional 省略した場合は App Engine の Instance class に従う (frontend 10min, backend 24h)
	DispatchDeadline time.Duration
}

GetTask is Get Request 用の Task

type Header struct {

	// QueueName is The name of the queue.
	// Always there
	QueueName string

	// TaskName is The "short" name of the task, or, if no name was specified at creation, a unique system-generated id.
	// This is the 'my-task-id' value in the complete task name, ie, task_name = projects/my-project-id/locations/my-location/queues/my-queue-id/tasks/my-task-id.
	// Always there
	TaskName string

	// TaskRetryCount is The number of times this task has been retried.
	// For the first attempt, this value is 0.
	// This number includes attempts where the task failed due to a lack of available instances and never reached the execution phase.
	// Always there
	TaskRetryCount int64

	// TaskExecutionCount is The total number of times that the task has received a response from the handler.
	// Since Cloud Tasks deletes the task once a successful response has been received, all previous handler responses were failures.
	// This number does not include failures due to a lack of available instances.
	// Always there
	TaskExecutionCount int64

	// TaskEAT is The schedule time of the task
	// Always there
	TaskETA time.Time

	// TaskPreviousResponse is The HTTP response code from the previous retry.
	// optional
	TaskPreviousResponse string

	// TaskRetryReason is The reason for retrying the task.
	// optional
	TaskRetryReason string

	// FailFast is Indicates that a task fails immediately if an existing instance is not available.
	// optional
	FailFast bool
}

Header is App Engine task handlers plz see https://cloud.google.com/tasks/docs/creating-appengine-handlers

func GetHeader

func GetHeader(r *http.Request) (*Header, error)

GetHeader return App Engine task header

type JsonPostTask

type JsonPostTask struct {
	// Task を Unique にしたい場合に設定する ID
	//
	// optional
	// 中で projects/PROJECT_ID/locations/LOCATION_ID/queues/QUEUE_ID/tasks/TASK_ID 形式に設定するので、TASK_ID の部分を設定する
	Name string

	// Task を到達させる App Engine の Service/Version
	// 設定しない場合は Queue の設定に従う
	// optional
	Routing *Routing

	// Task を到達させる path
	// "/" で始まる必要がある
	RelativeUri string

	// Body is JSON にして格納するもの
	Body interface{}

	// Task を実行する時刻
	// optional 省略した場合は即時実行
	ScheduleTime time.Time

	// Worker で Task を実行する Deadline
	// optional 省略した場合は App Engine の Instance class に従う (frontend 10min, backend 24h)
	DispatchDeadline time.Duration
}

JsonPostTask is JsonをBodyに入れるTask

type Queue

type Queue struct {
	ProjectID string
	Region    string
	Name      string
}

Queue is Cloud Tasks Queue

func (*Queue) Parent

func (q *Queue) Parent() string

Parent is return Cloud Tasks Parent format value

type Routing

type Routing struct {
	Service string
	Version string
}

Routing is Push 先の App EngineのServiceとVersionを指定するのに使う

type Service

type Service struct {
	// contains filtered or unexported fields
}

Service is App Engine Task Service

func NewService

func NewService(ctx context.Context, taskClient *cloudtasks.Client) (*Service, error)

NewService is return Service

func (*Service) CreateGetTask

func (s *Service) CreateGetTask(ctx context.Context, queue *Queue, task *GetTask) (string, error)

CreateGetTask is Get Request 用の Task を作る

func (*Service) CreateJsonPostTask

func (s *Service) CreateJsonPostTask(ctx context.Context, queue *Queue, task *JsonPostTask) (string, error)

CreateJsonPostTask is BodyにJsonを入れるTaskを作る

func (*Service) CreateTask

func (s *Service) CreateTask(ctx context.Context, queue *Queue, task *Task) (string, error)

CreateTask is QueueにTaskを作成する

type Task

type Task struct {
	// Task を Unique にしたい場合に設定する ID
	//
	// optional
	// 中で projects/PROJECT_ID/locations/LOCATION_ID/queues/QUEUE_ID/tasks/TASK_ID 形式に設定するので、TASK_ID の部分を設定する
	Name string

	// Task を到達させる App Engine の Service/Version
	// 設定しない場合は Queue の設定に従う
	// optional
	Routing *Routing

	// 任意の HTTP Request Header
	// optional
	Headers map[string]string

	// HTTP Method
	// optional 省略した場合は POST になる
	Method string

	// Task を到達させる path
	// "/" で始まる必要がある
	RelativeUri string

	// Http Request Body
	Body []byte

	// Task を実行する時刻
	// optional 省略した場合は即時実行
	ScheduleTime time.Time

	// Worker で Task を実行する Deadline
	// optional 省略した場合は App Engine の Instance class に従う (frontend 10min, backend 24h)
	DispatchDeadline time.Duration
}

Task is Task

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL