Documentation ¶
Overview ¶
Copyright © 2020 Marvin
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
Copyright © 2020 Marvin ¶
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
Copyright © 2020 Marvin ¶
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
Copyright © 2020 Marvin ¶
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
Index ¶
Constants ¶
const ( DefaultScheduledTaskSubmitPrefixKey = "/task/submit/" DefaultScheduledTaskKillPrefixKey = "/task/kill/" DefaultScheduledTaskLockPrefixKey = "/task/lock/" DefaultDistributedLockLease = 5 DefaultTaskActionSubmitEvent = 0 DefaultTaskActionDeleteEvent = 1 DefaultTaskActionKillEvent = 2 TaskDatabaseStatusWaiting = "WAITING" TaskDatabaseStatusRunning = "RUNNING" TaskDatabaseStatusStopped = "STOPPED" TaskDatabaseStatusFailed = "FAILED" TaskDatabaseStatusSuccess = "SUCCESS" TaskModeStructMigrate = "STRUCT_MIGRATE" )
Task
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Executor ¶
type Executor struct {
// contains filtered or unexported fields
}
func NewExecutor ¶
func (*Executor) PushTaskPlan ¶
type Plan ¶
type Plan struct { Addr string `json:"addr"` Task *Task `json:"task"` Expr *cronexpr.Expression `json:"-"` Next time.Time `json:"next"` // next schedule time Expected time.Time `json:"expected"` // expected schedule time Real time.Time `json:"real"` // real schedule time Status string `json:"status"` CancelCtx context.Context `json:"-"` // task cancel CancelFunc context.CancelFunc `json:"-"` }
type Scheduler ¶
type Scheduler struct { Ctx context.Context Executor *Executor TaskEventChan chan *Event TaskPlans map[string]*Plan }
func NewScheduler ¶
func (*Scheduler) HandleTaskEvent ¶
func (*Scheduler) PushTaskEvent ¶
func (*Scheduler) ScheduleEvent ¶
func (s *Scheduler) ScheduleEvent()
func (*Scheduler) Scheduling ¶
func (s *Scheduler) Scheduling()
func (*Scheduler) TryScheduling ¶
TryScheduling used for try schedule example: current time 0s, there are the three tasks,and they are executed once at 1s, 2s and 3s respectively now a b c 0s - 1s - 2s - 3s current only wait 1s