Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
OpenDAS
dynamo
Commits
fd0bcfa2
Commit
fd0bcfa2
authored
Feb 15, 2025
by
Ryan Olson
Committed by
GitHub
Feb 15, 2025
Browse files
refactor: adding facades for runtimes (#187)
parent
a52b3553
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
58 additions
and
2 deletions
+58
-2
runtime/rust/src/component.rs
runtime/rust/src/component.rs
+37
-1
runtime/rust/src/component/endpoint.rs
runtime/rust/src/component/endpoint.rs
+1
-1
runtime/rust/src/lib.rs
runtime/rust/src/lib.rs
+20
-0
No files found.
runtime/rust/src/component.rs
View file @
fd0bcfa2
...
...
@@ -43,7 +43,7 @@
use
crate
::
discovery
::
Lease
;
use
super
::{
error
,
transports
::
nats
::
Slug
,
DistributedRuntime
,
Result
};
use
super
::{
error
,
traits
::
*
,
transports
::
nats
::
Slug
,
DistributedRuntime
,
Result
,
Runtime
};
use
crate
::
pipeline
::
network
::{
ingress
::
push_endpoint
::
PushEndpoint
,
PushWorkHandler
};
use
async_nats
::{
...
...
@@ -108,6 +108,18 @@ pub struct Component {
namespace
:
String
,
}
impl
DistributedRuntimeProvider
for
Component
{
fn
drt
(
&
self
)
->
&
DistributedRuntime
{
&
self
.drt
}
}
impl
RuntimeProvider
for
Component
{
fn
rt
(
&
self
)
->
&
Runtime
{
self
.drt
.rt
()
}
}
impl
Component
{
pub
fn
etcd_path
(
&
self
)
->
String
{
format!
(
"{}/components/{}"
,
self
.namespace
,
self
.name
)
...
...
@@ -160,6 +172,18 @@ pub struct Endpoint {
name
:
String
,
}
impl
DistributedRuntimeProvider
for
Endpoint
{
fn
drt
(
&
self
)
->
&
DistributedRuntime
{
self
.component
.drt
()
}
}
impl
RuntimeProvider
for
Endpoint
{
fn
rt
(
&
self
)
->
&
Runtime
{
self
.component
.rt
()
}
}
impl
Endpoint
{
pub
fn
name
(
&
self
)
->
&
str
{
&
self
.name
...
...
@@ -206,6 +230,18 @@ pub struct Namespace {
name
:
String
,
}
impl
DistributedRuntimeProvider
for
Namespace
{
fn
drt
(
&
self
)
->
&
DistributedRuntime
{
&
self
.runtime
}
}
impl
RuntimeProvider
for
Namespace
{
fn
rt
(
&
self
)
->
&
Runtime
{
self
.runtime
.rt
()
}
}
impl
Namespace
{
pub
(
crate
)
fn
new
(
runtime
:
DistributedRuntime
,
name
:
String
)
->
Result
<
Self
>
{
Ok
(
NamespaceBuilder
::
default
()
...
...
runtime/rust/src/component/endpoint.rs
View file @
fd0bcfa2
...
...
@@ -41,7 +41,7 @@ impl EndpointConfigBuilder {
pub
async
fn
start
(
self
)
->
Result
<
()
>
{
let
(
endpoint
,
lease
,
handler
)
=
self
.build_internal
()
?
.dissolve
();
let
lease
=
lease
.unwrap_or
(
endpoint
.
component.
drt
.primary_lease
());
let
lease
=
lease
.unwrap_or
(
endpoint
.drt
()
.primary_lease
());
tracing
::
debug!
(
"Starting endpoint: {}"
,
...
...
runtime/rust/src/lib.rs
View file @
fd0bcfa2
...
...
@@ -79,3 +79,23 @@ pub struct DistributedRuntime {
// paths in etcd to a minimum.
component_registry
:
component
::
Registry
,
}
pub
mod
traits
{
use
super
::
*
;
/// A trait for objects taht proivde access to the [Runtime]
pub
trait
RuntimeProvider
{
fn
rt
(
&
self
)
->
&
Runtime
;
}
/// A trait for objects that provide access to the [DistributedRuntime].
pub
trait
DistributedRuntimeProvider
{
fn
drt
(
&
self
)
->
&
DistributedRuntime
;
}
impl
RuntimeProvider
for
DistributedRuntime
{
fn
rt
(
&
self
)
->
&
Runtime
{
&
self
.runtime
}
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment