-
Notifications
You must be signed in to change notification settings - Fork 25
/
nested-signal.go
59 lines (48 loc) · 1.97 KB
/
nested-signal.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
package components
import (
policylangv1 "github.com/fluxninja/aperture/v2/api/gen/proto/go/aperture/policy/language/v1"
"github.com/fluxninja/aperture/v2/pkg/policies/controlplane/iface"
"github.com/fluxninja/aperture/v2/pkg/policies/controlplane/runtime"
"go.uber.org/fx"
)
// NestedSignalPortName is the port name for nested signal ingress and egress components.
const NestedSignalPortName = "signal"
// nestedSignal is the base component for signal ingress and egress.
type nestedSignal struct {
NoOp
portName string
}
// Make sure nestedSignal complies with Component interface.
var _ runtime.Component = (*nestedSignal)(nil)
// PortName returns the port name.
func (nsi *nestedSignal) PortName() string {
return nsi.portName
}
// NestedSignalIngress is a component that ingresses a signal into a nested circuit.
type NestedSignalIngress struct {
nestedSignal
}
// NewNestedSignalIngressAndOptions creates a new NestedSignalIngress and its options.
func NewNestedSignalIngressAndOptions(nestedSignalIngressProto *policylangv1.NestedSignalIngress, _ runtime.ComponentID, _ iface.Policy) (runtime.Component, fx.Option, error) {
comp := NestedSignalIngress{}
comp.portName = nestedSignalIngressProto.PortName
return &comp, fx.Options(), nil
}
// Name returns the name of the component.
func (nsi *NestedSignalIngress) Name() string {
return "NestedSignalIngress"
}
// NestedSignalEgress is a component that ingresses a signal into a nested circuit.
type NestedSignalEgress struct {
nestedSignal
}
// NewNestedSignalEgressAndOptions creates a new NestedSignalEgress and its options.
func NewNestedSignalEgressAndOptions(nestedSignalEgressProto *policylangv1.NestedSignalEgress, _ runtime.ComponentID, _ iface.Policy) (runtime.Component, fx.Option, error) {
comp := NestedSignalEgress{}
comp.portName = nestedSignalEgressProto.PortName
return &comp, fx.Options(), nil
}
// Name returns the name of the component.
func (nse *NestedSignalEgress) Name() string {
return "NestedSignalEgress"
}