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