-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmetadata.go
More file actions
44 lines (35 loc) · 1.19 KB
/
metadata.go
File metadata and controls
44 lines (35 loc) · 1.19 KB
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
package abi
import (
"time"
)
// RunMetadata contains execution metadata for SDK operations.
type RunMetadata struct {
// StartTime is when the operation started.
StartTime time.Time `json:"start_time"`
// EndTime is when the operation completed.
EndTime time.Time `json:"end_time"`
// SDKVersion is the version of the SDK that executed the operation.
SDKVersion string `json:"sdk_version,omitempty"`
// PluginID identifies the plugin that requested the operation (if known).
PluginID string `json:"plugin_id,omitempty"`
// Duration is the total execution time.
Duration time.Duration `json:"duration_ns"`
}
// NewRunMetadata creates a new RunMetadata with the given start and end times.
func NewRunMetadata(start, end time.Time) *RunMetadata {
return &RunMetadata{
StartTime: start,
EndTime: end,
Duration: end.Sub(start),
}
}
// WithSDKVersion returns a copy of the RunMetadata with the SDK version set.
func (m *RunMetadata) WithSDKVersion(version string) *RunMetadata {
m.SDKVersion = version
return m
}
// WithPluginID returns a copy of the RunMetadata with the plugin ID set.
func (m *RunMetadata) WithPluginID(pluginID string) *RunMetadata {
m.PluginID = pluginID
return m
}