Documentation ¶
Index ¶
- Constants
- Variables
- func HttpMethodProtoToHttpMethod(method taskspb.HttpMethod) (string, error)
- func NewErrInvalidArgument(message string, kv map[string]interface{}, err error) error
- func NewErrInvalidHeader(message string, kv map[string]interface{}, err error) error
- func ValidateJWTFromHttpTargetTask(ctx context.Context, r *http.Request, projectNumber string, projectID string) (*auth.JWTPayload, error)
- type CreateTaskOptions
- type Error
- type GetTask
- type Header
- type JsonPostTask
- type MultiError
- type Queue
- type Routing
- type Service
- func (s *Service) CreateGetTask(ctx context.Context, queue *Queue, task *GetTask, ops ...CreateTaskOptions) (string, error)
- func (s *Service) CreateGetTaskMulti(ctx context.Context, queue *Queue, tasks []*GetTask, ops ...CreateTaskOptions) ([]string, error)
- func (s *Service) CreateJsonPostTask(ctx context.Context, queue *Queue, task *JsonPostTask, ...) (string, error)
- func (s *Service) CreateJsonPostTaskMulti(ctx context.Context, queue *Queue, tasks []*JsonPostTask, ...) ([]string, error)
- func (s *Service) CreateTask(ctx context.Context, queue *Queue, task *Task, ops ...CreateTaskOptions) (string, error)
- func (s *Service) CreateTaskMulti(ctx context.Context, queue *Queue, tasks []*Task, ops ...CreateTaskOptions) ([]string, error)
- type Task
Constants ¶
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 ¶
var ErrAlreadyExists = &Error{ Code: "AlreadyExists", Message: "AlreadyExists", KV: map[string]interface{}{}, }
ErrAlreadyExists is すでに存在している場合の Error 主に TaskName が重複した場合に返す https://cloud.google.com/tasks/docs/reference/rest/v2/projects.locations.queues.tasks/create#body.request_body.FIELDS.task
var ErrCreateMultiTask = &Error{ Code: "FailedCreateMultiTask", Message: "FailedCreateMultiTask", KV: map[string]interface{}{}, }
ErrCreateMultiTask is CreateMultiTask の時に MultiError に入れる Error
var ErrInvalidArgument = &Error{ Code: "InvalidArgument", Message: "InvalidArgument", KV: map[string]interface{}{}, }
ErrInvalidRequest is 引数が invalid な時に返す
var ErrInvalidHeader = &Error{ Code: "InvalidHeader", Message: "InvalidHeader", KV: map[string]interface{}{}, }
ErrInvalidHeader is Header が invalid な時に返す
var ErrNotFoundHeader = errors.New("not found cloudtasks header")
ErrNotFoundHeader is Cloud Tasks の Headerがない時に利用されます。
Functions ¶
func HttpMethodProtoToHttpMethod ¶ added in v1.3.2
func HttpMethodProtoToHttpMethod(method taskspb.HttpMethod) (string, error)
HttpMethodProtoToHttpMethod is HttpMethodProto から HttpMethod に変換する
func NewErrInvalidArgument ¶ added in v1.3.0
NewErrInvalidArgument is return ErrInvalidArgument
func NewErrInvalidHeader ¶ added in v1.3.0
NewErrInvalidHeader is return ErrInvalidHeader
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 CreateTaskOptions ¶ added in v1.3.0
type CreateTaskOptions func(*createTaskOptions)
CreateTaskOptions is CreateTask に利用する options
func WithIgnoreAlreadyExists ¶ added in v1.3.0
func WithIgnoreAlreadyExists() CreateTaskOptions
WithIgnoreAlreadyExists is CreateTask 時に AlreadyExists を無視する TaskName を指定した状態での Retry 時にすでにAddされているものは無視すればよい場合に使う
type Error ¶ added in v1.3.0
type Error struct { Code string Message string KV map[string]interface{} // contains filtered or unexported fields }
Error is Error情報を保持する struct
func NewErrAlreadyExists ¶ added in v1.3.0
NewErrAlreadyExists is return ErrAlreadyExists
func NewErrCreateMultiTask ¶ added in v1.3.0
NewErrCreateMultiTask is return ErrCreateMultiTask
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 ¶
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
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 // 任意の HTTP Request Header // optional Headers map[string]string // 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
func (*JsonPostTask) ToTask ¶ added in v1.3.2
func (jpTask *JsonPostTask) ToTask() (*Task, error)
ToTask is JsonPostTask convert to Task
type MultiError ¶ added in v1.3.0
type MultiError struct { Errors []*Error // contains filtered or unexported fields }
MultiError is 複数の error を返す
func (*MultiError) Append ¶ added in v1.3.0
func (e *MultiError) Append(err *Error)
func (*MultiError) Error ¶ added in v1.3.0
func (e *MultiError) Error() string
func (*MultiError) ErrorOrNil ¶ added in v1.3.0
func (e *MultiError) ErrorOrNil() error
func (*MultiError) Is ¶ added in v1.3.0
func (e *MultiError) Is(target error) bool
Is is err equal check
func (*MultiError) Unwrap ¶ added in v1.3.0
func (e *MultiError) Unwrap() error
Unwrap is return unwrap error
type Routing ¶
Routing is Push 先の App EngineのServiceとVersionを指定するのに使う
func AppEngineRoutingProtoToRouting ¶ added in v1.3.2
func AppEngineRoutingProtoToRouting(routing *taskspb.AppEngineRouting) (*Routing, error)
AppEngineRoutingProtoToRouting is AppEngineRouting から Routing に変換する
type Service ¶
type Service struct {
// contains filtered or unexported fields
}
Service is App Engine Task Service
func NewService ¶
NewService is return serviceImple
func (*Service) CreateGetTask ¶
func (s *Service) CreateGetTask(ctx context.Context, queue *Queue, task *GetTask, ops ...CreateTaskOptions) (string, error)
CreateGetTask is Get Request 用の Task を作る
func (*Service) CreateGetTaskMulti ¶ added in v1.3.1
func (s *Service) CreateGetTaskMulti(ctx context.Context, queue *Queue, tasks []*GetTask, ops ...CreateTaskOptions) ([]string, error)
CreateGetTaskMulti is Queue に複数の GetTask を作成する
func (*Service) CreateJsonPostTask ¶
func (s *Service) CreateJsonPostTask(ctx context.Context, queue *Queue, task *JsonPostTask, ops ...CreateTaskOptions) (string, error)
CreateJsonPostTask is BodyにJsonを入れるTaskを作る
func (*Service) CreateJsonPostTaskMulti ¶ added in v1.3.1
func (s *Service) CreateJsonPostTaskMulti(ctx context.Context, queue *Queue, tasks []*JsonPostTask, ops ...CreateTaskOptions) ([]string, error)
CreateJsonPostTaskMulti is Queue に 複数の JsonPostTask を作成する
func (*Service) CreateTask ¶
func (s *Service) CreateTask(ctx context.Context, queue *Queue, task *Task, ops ...CreateTaskOptions) (string, error)
CreateTask is QueueにTaskを作成する
func (*Service) CreateTaskMulti ¶ added in v1.3.0
func (s *Service) CreateTaskMulti(ctx context.Context, queue *Queue, tasks []*Task, ops ...CreateTaskOptions) ([]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
func (*Task) ToCreateTaskRequestProto ¶ added in v1.3.2
func (task *Task) ToCreateTaskRequestProto(queue *Queue) (*taskspb.CreateTaskRequest, error)
ToCreateTaskRequestProto is CreateTaskRequest に変換する