Skip to content

Commit

Permalink
Updated function from 'localhost' to 'get_uri'
Browse files Browse the repository at this point in the history
  • Loading branch information
devkelley committed Oct 9, 2023
1 parent 90cce18 commit ba8db1a
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 18 deletions.
14 changes: 3 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -303,9 +303,7 @@ command in the project root directory:
1. To detach from the container, enter:
```shell
Ctrl-p Ctrl-q
```
<kbd>Ctrl</kbd> + <kbd>p</kbd>, <kbd>Ctrl</kbd> + <kbd>q</kbd>
1. To stop the container, enter:
Expand Down Expand Up @@ -347,16 +345,10 @@ root directory:
podman run -p 50051:50051 --env-file=podman.env --network=slirp4netns:allow_host_loopback=true localhost/pub_sub_service
```

1. To stop the container, find the container with:

```shell
podman ps
```

Then run:
1. To stop the container, run:

```shell
podman stop <container_name>
podman ps -f ancestor=localhost/pub_sub_service:latest --format="{{.Names}}" | xargs podman stop
```

#### Notes
Expand Down
4 changes: 2 additions & 2 deletions pub-sub-service/src/connectors/chariott_connector.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ use proto::{
service_registry::v1::{RegisterRequest, ServiceMetadata},
};

use crate::load_config::localhost;
use crate::load_config::get_uri;

type ChariottClient = ServiceRegistryClient<Channel>;

Expand Down Expand Up @@ -41,7 +41,7 @@ pub async fn connect_to_chariott_with_retry(
let mut reason = String::new();

while client_opt.is_none() {
client_opt = match ServiceRegistryClient::connect(localhost(chariott_uri)).await {
client_opt = match ServiceRegistryClient::connect(get_uri(chariott_uri)).await {
Ok(client) => Some(client),
Err(e) => {
let status = Status::from_error(Box::new(e));
Expand Down
4 changes: 2 additions & 2 deletions pub-sub-service/src/connectors/mosquitto_connector.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ use paho_mqtt::{self as mqtt, MQTT_VERSION_5};
use std::{process, sync::mpsc};

use crate::{
load_config::localhost,
load_config::get_uri,
pubsub_connector::{self, MonitorMessage, PubSubAction, PubSubConnector},
};

Expand All @@ -39,7 +39,7 @@ impl MqttFiveBrokerConnector {
/// * `client_id` - Id used when creating a new mqtt client.
/// * `broker_uri` - The uri of the broker that the client is connecting to.
fn new(client_id: String, broker_uri: String) -> Self {
let host = localhost(&broker_uri);
let host = get_uri(&broker_uri);

let create_opts = mqtt::CreateOptionsBuilder::new()
.server_uri(host)
Expand Down
2 changes: 1 addition & 1 deletion pub-sub-service/src/load_config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ const CONSTANTS_FILE: &str = "target/debug/constants_settings";
///
/// # Arguments
/// * `uri` - The uri to potentially modify.
pub fn localhost(uri: &str) -> String {
pub fn get_uri(uri: &str) -> String {
#[cfg(feature = "containerize")]
let uri = {
// Container env variable names.
Expand Down
4 changes: 2 additions & 2 deletions pub-sub-service/src/topic_manager.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ use proto::publisher::v1::{
use tonic::Request;

use crate::{
load_config::localhost,
load_config::get_uri,
pubsub_connector::{MonitorMessage, PubSubAction},
};

Expand Down Expand Up @@ -298,7 +298,7 @@ impl TopicManager {

// Get information from publisher client
let mut pub_client =
PublisherCallbackClient::connect(localhost(&action_metadata.uri)).await?;
PublisherCallbackClient::connect(get_uri(&action_metadata.uri)).await?;

let request = Request::new(ManageTopicRequest {
topic: action_metadata.topic.clone(),
Expand Down

0 comments on commit ba8db1a

Please sign in to comment.