Exposes Module.IsClosed to prevent calling functions when closed (#1573)
Signed-off-by: Adrian Cole <adrian@tetrate.io> Co-authored-by: Takeshi Yoneda <takeshi@tetrate.io>
This commit is contained in:
@@ -106,6 +106,11 @@ func (m *ModuleInstance) CloseWithExitCode(ctx context.Context, exitCode uint32)
|
||||
return m.ensureResourcesClosed(ctx)
|
||||
}
|
||||
|
||||
// IsClosed implements the same method as documented on api.Module.
|
||||
func (m *ModuleInstance) IsClosed() bool {
|
||||
return atomic.LoadUint64(&m.Closed) != 0
|
||||
}
|
||||
|
||||
func (m *ModuleInstance) closeWithExitCodeWithoutClosingResource(exitCode uint32) (err error) {
|
||||
if !m.setExitCode(exitCode, exitCodeFlagResourceNotClosed) {
|
||||
return nil // not an error to have already closed
|
||||
|
||||
Reference in New Issue
Block a user