-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathoperator.go
105 lines (74 loc) · 3.33 KB
/
operator.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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
package def
// An operator is a net of instances defined by a set of instances and connections.
type Instance struct {
// Specification contains information to specify an instance.
Specification InstanceSpecification `json:"specification,omitempty" yaml:"specification,omitempty"`
// Operator contains the actual implementation.
Operator Operator `json:"operator,omitempty" yaml:"operator,omitempty"`
}
type InstanceSpecification struct {
// Values specifies the properties used in this operator.
Values Values `json:"values,omitempty" yaml:"values,omitempty"`
// Generics specifies the generics used in this operator.
Generics Generics `json:"generics,omitempty" yaml:"generics,omitempty"`
// Embedding assigns an operator to each delegate.
Embedding Embedding `json:"embedding,omitempty" yaml:"embedding,omitempty"`
}
type OperatorType string
type OperatorReference string
type Operator struct {
// Description of this operator in natural language (English).
Description string `json:"description" yaml:"description"`
// Reference to an operator.
Reference OperatorReference `json:"reference,omitempty" yaml:"reference,omitempty"`
// Elementary
Elementary string `json:"elementary,omitempty" yaml:"elementary,omitempty"`
// Properties is the definition for the structure of the values needed by this operator.
Properties Properties `json:"properties,omitempty" yaml:"properties,omitempty"`
// Services
Services map[ServiceName]*Operation `json:"services" yaml:"services"`
// In case Type == "implementation"
// Delegates
Delegates Instances `json:"delegates,omitempty" yaml:"delegates,omitempty"`
// Instances is a map of all child instances inside this operator.
Instances Instances `json:"instances,omitempty" yaml:"instances,omitempty"`
// Implementations
Implementation map[ServiceName]*struct {
// Handles can be referenced in connections.
// There can be an arbitrary number of handles for each service.
// The default service is called "main".
Handles Handles `json:"handles" yaml:"handles"`
// Connections defines the path all data takes through this operator.
// It connects the child operators with each other and with this interface.
Connections Connections `json:"connections,omitempty" yaml:"connections,omitempty"`
} `json:"implementation,omitempty" yaml:"implementation,omitempty"`
}
type InstanceService struct {
Delegate InstanceName `json:"delegate" yaml:"instance"`
Instance InstanceName `json:"instance" yaml:"instance"`
Service ServiceName `json:"service" yaml:"service"`
}
type Handles map[HandleID]*InstanceService
type Values map[string]interface{}
// Embedding specifies how to embed a child operator into this implementation.
type Embedding map[InstanceName]map[ServiceName]*InstanceService
type Properties map[string]*Type
type Instances map[InstanceName]*Instance
type Connections map[ConnectionID]*struct {
Source struct {
Handle HandleID `json:"handle" yaml:"handle"`
Port InPortID `json:"port" yaml:"port"`
} `json:"source" yaml:"source"`
Destination struct {
Handle HandleID `json:"handle" yaml:"handle"`
Port OutPortID `json:"port" yaml:"port"`
} `json:"destination" yaml:"destination"`
}
type ServiceName string
type DelegateName string
type ResourceID string
type HandleID string
type InstanceName string
type ConnectionID string
type InPortID string
type OutPortID string