-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
220 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
/* Copyright 2019 Freerware | ||
* | ||
* 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. | ||
*/ | ||
package work | ||
|
||
// Action represents an operation performed during a paticular lifecycle event of a work unit. | ||
type UnitAction func(UnitContext) | ||
|
||
// ActionType represents the type of work unit action. | ||
type ActionType int | ||
|
||
// The various types of actions that are executed throughout the lifecycle of a work unit. | ||
const ( | ||
// ActionTypeAfterRegister indicates an action type that occurs after an entity is registered. | ||
ActionTypeAfterRegister = iota | ||
// ActionTypeAfterAdd indicates an action type that occurs after an entity is added. | ||
ActionTypeAfterAdd | ||
// ActionTypeAfterAlter indicates an action type that occurs after an entity is altered. | ||
ActionTypeAfterAlter | ||
// ActionTypeAfterRemove indicates an action type that occurs after an entity is removed. | ||
ActionTypeAfterRemove | ||
// ActionTypeAfterInserts indicates an action type that occurs after new entities are inserted in the data store. | ||
ActionTypeAfterInserts | ||
// ActionTypeAfterUpdates indicates an action type that occurs after existing entities are updated in the data store. | ||
ActionTypeAfterUpdates | ||
// ActionTypeAfterDeletes indicates an action type that occurs after existing entities are deleted in the data store. | ||
ActionTypeAfterDeletes | ||
// ActionTypeAfterRollback indicates an action type that occurs after rollback. | ||
ActionTypeAfterRollback | ||
// ActionTypeAfterSave indicates an action type that occurs after save. | ||
ActionTypeAfterSave | ||
// ActionTypeBeforeRegister indicates an action type that occurs before an entity is registered. | ||
ActionTypeBeforeRegister | ||
// ActionTypeBeforeAdd indicates an action type that occurs before an entity is added. | ||
ActionTypeBeforeAdd | ||
// ActionTypeBeforeAlter indicates an action type that occurs before an entity is altered. | ||
ActionTypeBeforeAlter | ||
// ActionTypeBeforeRemove indicates an action type that occurs before an entity is removed. | ||
ActionTypeBeforeRemove | ||
// ActionTypeBeforeInserts indicates an action type that occurs before new entities are inserted in the data store. | ||
ActionTypeBeforeInserts | ||
// ActionTypeBeforeUpdates indicates an action type that occurs before existing entities are updated in the data store. | ||
ActionTypeBeforeUpdates | ||
// ActionTypeBeforeDeletes indicates an action type that occurs before existing entities are deleted in the data store. | ||
ActionTypeBeforeDeletes | ||
// ActionTypeBeforeRollback indicates an action type that occurs before rollback. | ||
ActionTypeBeforeRollback | ||
// ActionTypeBeforeSave indicates an action type that occurs before save. | ||
ActionTypeBeforeSave | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
/* Copyright 2019 Freerware | ||
* | ||
* 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. | ||
*/ | ||
|
||
package work | ||
|
||
import "go.uber.org/zap" | ||
|
||
// UnitContext represents context about a work unit passed through to work unit actions. | ||
type UnitContext struct { | ||
logger *zap.Logger | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters