github.com/ava-labs/avalanchego@v1.11.11/vms/rpcchainvm/runtime/runtime.go (about) 1 // Copyright (C) 2019-2024, Ava Labs, Inc. All rights reserved. 2 // See the file LICENSE for licensing terms. 3 4 package runtime 5 6 import ( 7 "context" 8 "errors" 9 "time" 10 ) 11 12 const ( 13 // Address of the runtime engine server. 14 EngineAddressKey = "AVALANCHE_VM_RUNTIME_ENGINE_ADDR" 15 16 // Duration before handshake timeout during bootstrap. 17 DefaultHandshakeTimeout = 5 * time.Second 18 19 // Duration of time to wait for graceful termination to complete. 20 DefaultGracefulTimeout = 5 * time.Second 21 ) 22 23 var ( 24 ErrProtocolVersionMismatch = errors.New("RPCChainVM protocol version mismatch between AvalancheGo and Virtual Machine plugin") 25 ErrHandshakeFailed = errors.New("handshake failed") 26 ErrInvalidConfig = errors.New("invalid config") 27 ErrProcessNotFound = errors.New("vm process not found") 28 ) 29 30 type Initializer interface { 31 // Initialize provides AvalancheGo with compatibility, networking and 32 // process information of a VM. 33 Initialize(ctx context.Context, protocolVersion uint, vmAddr string) error 34 } 35 36 type Stopper interface { 37 // Stop begins shutdown of a VM. This method must not block 38 // and multiple calls to this method will result in no-op. 39 Stop(ctx context.Context) 40 } 41 42 type Tracker interface { 43 // TrackRuntime adds a VM stopper to the manager. 44 TrackRuntime(runtime Stopper) 45 } 46 47 type Manager interface { 48 Tracker 49 // Stop all managed VMs. 50 Stop(ctx context.Context) 51 }