allora_runtime/spec/
allora_spec.rs1use crate::spec::{
31 AggregatorsSpec, ChannelsSpec, FiltersSpec, HttpInboundAdaptersSpec, HttpOutboundAdaptersSpec,
32 ServiceActivatorsSpec,
33};
34
35#[derive(Debug, Clone)]
36pub struct AlloraSpec {
37 version: u32,
38 channels: ChannelsSpec,
39 filters: Option<FiltersSpec>,
40 services: Option<ServiceActivatorsSpec>,
41 http_inbound_adapters: Option<HttpInboundAdaptersSpec>,
42 http_outbound_adapters: Option<HttpOutboundAdaptersSpec>,
43 aggregators: Option<AggregatorsSpec>,
44}
45
46impl AlloraSpec {
47 pub fn new(version: u32, channels: ChannelsSpec) -> Self {
48 Self {
49 version,
50 channels,
51 filters: None,
52 services: None,
53 http_inbound_adapters: None,
54 http_outbound_adapters: None,
55 aggregators: None,
56 }
57 }
58 pub fn new_with_filters(
61 version: u32,
62 channels: ChannelsSpec,
63 filters: Option<FiltersSpec>,
64 ) -> Self {
65 Self {
66 version,
67 channels,
68 filters,
69 services: None,
70 http_inbound_adapters: None,
71 http_outbound_adapters: None,
72 aggregators: None,
73 }
74 }
75 pub fn with_filters(mut self, filters: FiltersSpec) -> Self {
76 self.filters = Some(filters);
77 self
78 }
79 pub fn with_services(mut self, services: ServiceActivatorsSpec) -> Self {
80 self.services = Some(services);
81 self
82 }
83 pub fn with_http_inbound_adapters(mut self, adapters: HttpInboundAdaptersSpec) -> Self {
84 self.http_inbound_adapters = Some(adapters);
85 self
86 }
87 pub fn with_http_outbound_adapters(mut self, adapters: HttpOutboundAdaptersSpec) -> Self {
88 self.http_outbound_adapters = Some(adapters);
89 self
90 }
91 pub fn with_aggregators(mut self, aggregators: AggregatorsSpec) -> Self {
92 self.aggregators = Some(aggregators);
93 self
94 }
95 pub fn version(&self) -> u32 {
96 self.version
97 }
98 pub fn channels_spec(&self) -> &ChannelsSpec {
99 &self.channels
100 }
101 pub fn filters_spec(&self) -> Option<&FiltersSpec> {
102 self.filters.as_ref()
103 }
104 pub fn services_spec(&self) -> Option<&ServiceActivatorsSpec> {
105 self.services.as_ref()
106 }
107 pub fn http_inbound_adapters_spec(&self) -> Option<&HttpInboundAdaptersSpec> {
108 self.http_inbound_adapters.as_ref()
109 }
110 pub fn http_outbound_adapters_spec(&self) -> Option<&HttpOutboundAdaptersSpec> {
111 self.http_outbound_adapters.as_ref()
112 }
113 pub fn aggregators_spec(&self) -> Option<&AggregatorsSpec> {
114 self.aggregators.as_ref()
115 }
116 pub fn into_channels_spec(self) -> ChannelsSpec {
117 self.channels
118 }
119 pub fn into_filters_spec(self) -> Option<FiltersSpec> {
120 self.filters
121 }
122 pub fn into_services_spec(self) -> Option<ServiceActivatorsSpec> {
123 self.services
124 }
125 pub fn into_http_inbound_adapters_spec(self) -> Option<HttpInboundAdaptersSpec> {
126 self.http_inbound_adapters
127 }
128 pub fn into_http_outbound_adapters_spec(self) -> Option<HttpOutboundAdaptersSpec> {
129 self.http_outbound_adapters
130 }
131 pub fn into_aggregators_spec(self) -> Option<AggregatorsSpec> {
132 self.aggregators
133 }
134}