func (inst *Instance) FlowDefinition() *definition.Definition {
	return inst.flowDef
}
FlowDefinition returns the Flow definition associated with this context
package instance
import (
	"strconv"
	"github.com/project-flogo/core/action"
	"github.com/project-flogo/core/data"
	"github.com/project-flogo/core/data/metadata"
	"github.com/project-flogo/core/support/log"
	"github.com/project-flogo/core/support/trace"
	"github.com/project-flogo/flow/definition"
	"github.com/project-flogo/flow/model"
)
type Instance struct {
	subflowId int
	master *IndependentInstance  
	host   interface{}           
	isHandlingError bool
	status  model.FlowStatus
	flowDef *definition.Definition
	flowURI string  
	taskInsts map[string]*TaskInst
	linkInsts map[int]*LinkInst
	forceCompletion bool
	returnData      map[string]interface{}
	returnError     error
	attrs map[string]interface{}
	resultHandler action.ResultHandler
	logger     log.Logger
	tracingCtx trace.TracingContext
}
func (inst *Instance) GetMasterScope() data.Scope {
	return inst.master
}
func (inst *Instance) FlowURI() string {
	return inst.flowURI
}
func (inst *Instance) Name() string {
	return inst.flowDef.Name()
}
func (inst *Instance) ID() string {
	if inst.subflowId > 0 {
		return inst.master.id + "-" + strconv.Itoa(inst.subflowId)
	}
	return inst.master.id
}
func (inst *Instance) TracingContext() trace.TracingContext {
	return inst.tracingCtx
}
func (inst *Instance) SetResultHandler(handler action.ResultHandler) {
	inst.resultHandler = handler
}
func (inst *Instance) FindOrCreateTaskInst(task *definition.Task) (taskInst *TaskInst, created bool) {
	taskInst, ok := inst.taskInsts[task.ID()]
	created = false
	if !ok {
		taskInst = NewTaskInst(inst, task)
		inst.taskInsts[task.ID()] = taskInst
		inst.master.changeTracker.TaskAdded(taskInst)
		created = true
	}
	return taskInst, created
}
func (inst *Instance) FindOrCreateLinkData(link *definition.Link) (linkInst *LinkInst, created bool) {
	linkInst, ok := inst.linkInsts[link.ID()]
	created = false
	if !ok {
		linkInst = NewLinkInst(inst, link)
		inst.linkInsts[link.ID()] = linkInst
		inst.master.changeTracker.LinkAdded(linkInst)
		created = true
	}
	return linkInst, created
}
func (inst *Instance) releaseTask(task *definition.Task) {
	delete(inst.taskInsts, task.ID())
	inst.master.changeTracker.TaskRemoved(inst.subflowId, task.ID())
	links := task.FromLinks()
	for _, link := range links {
		delete(inst.linkInsts, link.ID())
		inst.master.changeTracker.LinkRemoved(inst.subflowId, link.ID())
	}
}
func (inst *Instance) IOMetadata() *metadata.IOMetadata {
	return inst.flowDef.Metadata()
}
func (inst *Instance) Reply(replyData map[string]interface{}, err error) {
	if inst.resultHandler != nil {
		inst.resultHandler.HandleResult(replyData, err)
	}
}
func (inst *Instance) Return(returnData map[string]interface{}, err error) {
	inst.forceCompletion = true
	inst.returnData = returnData
	inst.returnError = err
}
func (inst *Instance) Scope() data.Scope {
	return inst
}
func (inst *Instance) GetError() error {
	return inst.returnError
}
func (inst *Instance) GetReturnData() (map[string]interface{}, error) {
	if inst.returnData == nil {
		md := inst.flowDef.Metadata()
		if md != nil && md.Output != nil {
			inst.returnData = make(map[string]interface{})
			for name := range md.Output {
				piAttr, exists := inst.attrs[name]
				if exists {
					inst.returnData[name] = piAttr
				}
				if md.Output[name].Value() != nil {
					inst.returnData[name] = md.Output[name].Value()
				}
			}
		}
	}
	return inst.returnData, inst.returnError
}
func (inst *Instance) Status() model.FlowStatus {
	return inst.status
}
func (inst *Instance) SetStatus(status model.FlowStatus) {
	inst.status = status
	inst.master.changeTracker.SetStatus(inst.subflowId, status)
	postFlowEvent(inst)
}