VOL-2180 code changes for context addition
Integrating InterContainerProxy interface changes
Change-Id: Ia20c5ac3093b7845acf80cce801ec0c1d90c125f
diff --git a/adaptercore/olt_state_transitions.go b/adaptercore/olt_state_transitions.go
index 697ee5f..51b7ef0 100644
--- a/adaptercore/olt_state_transitions.go
+++ b/adaptercore/olt_state_transitions.go
@@ -18,6 +18,7 @@
package adaptercore
import (
+ "context"
"reflect"
"runtime"
@@ -57,7 +58,7 @@
)
// TransitionHandler function type for handling transition
-type TransitionHandler func() error
+type TransitionHandler func(ctx context.Context) error
// Transition to store state machine
type Transition struct {
@@ -144,7 +145,7 @@
// Handle moves the state machine to next state based on the trigger and invokes the before and
// after handlers if the transition is a valid transition
-func (tMap *TransitionMap) Handle(trigger Trigger) {
+func (tMap *TransitionMap) Handle(ctx context.Context, trigger Trigger) {
// Check whether the transtion is valid from current state
if !tMap.isValidTransition(trigger) {
@@ -159,7 +160,7 @@
}
for _, handler := range beforeHandlers {
log.Debugw("running-before-handler", log.Fields{"handler": funcName(handler)})
- if err := handler(); err != nil {
+ if err := handler(ctx); err != nil {
// TODO handle error
log.Error(err)
return
@@ -177,7 +178,7 @@
}
for _, handler := range afterHandlers {
log.Debugw("running-after-handler", log.Fields{"handler": funcName(handler)})
- if err := handler(); err != nil {
+ if err := handler(ctx); err != nil {
// TODO handle error
log.Error(err)
return