Skip to content

Added amqp, fixed examples, lint, and tests #25

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 1 commit into
base: candidate-0.9.0
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 15 additions & 11 deletions examples/1_hello_world/hello_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,14 @@

from intersect_sdk import (
INTERSECT_JSON_VALUE,
ControlPlaneConfig,
IntersectClient,
IntersectClientCallback,
IntersectClientConfig,
IntersectDirectMessageParams,
default_intersect_lifecycle_loop,
)
from intersect_sdk.config.shared import BrokerConfig

logging.basicConfig(level=logging.INFO)

Expand Down Expand Up @@ -42,16 +44,18 @@ def simple_client_callback(

In most cases, everything under from_config_file should come from a configuration file, command line arguments, or environment variables.
"""
from_config_file = {
'brokers': [
{
'username': 'intersect_username',
'password': 'intersect_password',
'port': 1883,
'protocol': 'mqtt3.1.1',
},
],
}
broker_configs = [
{'host': 'localhost', 'port': 1883},
]

brokers = [
ControlPlaneConfig(
protocol='mqtt3.1.1',
username='intersect_username',
password='intersect_password',
brokers=[BrokerConfig(**broker) for broker in broker_configs],
)
]
"""
step two: construct the initial messages you want to send. In this case we will only send a single starting message.

Expand All @@ -73,7 +77,7 @@ def simple_client_callback(
]
config = IntersectClientConfig(
initial_message_event_config=IntersectClientCallback(messages_to_send=initial_messages),
**from_config_file,
brokers=brokers,
)

"""
Expand Down
27 changes: 16 additions & 11 deletions examples/1_hello_world/hello_service.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import logging

from intersect_sdk import (
ControlPlaneConfig,
HierarchyConfig,
IntersectBaseCapabilityImplementation,
IntersectService,
Expand All @@ -9,6 +10,7 @@
intersect_message,
intersect_status,
)
from intersect_sdk.config.shared import BrokerConfig

logging.basicConfig(level=logging.INFO)
logger = logging.getLogger(__name__)
Expand Down Expand Up @@ -44,16 +46,19 @@ def say_hello_to_name(self, name: str) -> str:

In most cases, everything under from_config_file should come from a configuration file, command line arguments, or environment variables.
"""
from_config_file = {
'brokers': [
{
'username': 'intersect_username',
'password': 'intersect_password',
'port': 1883,
'protocol': 'mqtt3.1.1',
},
],
}
broker_configs = [
{'host': 'localhost', 'port': 1883},
]

brokers = [
ControlPlaneConfig(
protocol='mqtt3.1.1',
username='intersect_username',
password='intersect_password',
brokers=[BrokerConfig(**broker) for broker in broker_configs],
)
]

config = IntersectServiceConfig(
hierarchy=HierarchyConfig(
organization='hello-organization',
Expand All @@ -62,7 +67,7 @@ def say_hello_to_name(self, name: str) -> str:
subsystem='hello-subsystem',
service='hello-service',
),
**from_config_file,
brokers=brokers,
)

"""
Expand Down
26 changes: 15 additions & 11 deletions examples/1_hello_world_amqp/hello_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,14 @@

from intersect_sdk import (
INTERSECT_JSON_VALUE,
ControlPlaneConfig,
IntersectClient,
IntersectClientCallback,
IntersectClientConfig,
IntersectDirectMessageParams,
default_intersect_lifecycle_loop,
)
from intersect_sdk.config.shared import BrokerConfig

logging.basicConfig(level=logging.INFO)
logging.getLogger('pika').setLevel(logging.WARNING)
Expand Down Expand Up @@ -43,16 +45,18 @@ def simple_client_callback(

In most cases, everything under from_config_file should come from a configuration file, command line arguments, or environment variables.
"""
from_config_file = {
'brokers': [
{
'username': 'intersect_username',
'password': 'intersect_password',
'port': 5672,
'protocol': 'amqp0.9.1',
},
],
}
broker_configs = [
{'host': 'localhost', 'port': 5672},
]

brokers = [
ControlPlaneConfig(
protocol='amqp0.9.1',
username='intersect_username',
password='intersect_password',
brokers=[BrokerConfig(**broker) for broker in broker_configs],
)
]

"""
step two: construct the initial messages you want to send. In this case we will only send a single starting message.
Expand All @@ -75,7 +79,7 @@ def simple_client_callback(
]
config = IntersectClientConfig(
initial_message_event_config=IntersectClientCallback(messages_to_send=initial_messages),
**from_config_file,
brokers=brokers,
)

"""
Expand Down
27 changes: 16 additions & 11 deletions examples/1_hello_world_amqp/hello_service.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import logging

from intersect_sdk import (
ControlPlaneConfig,
HierarchyConfig,
IntersectBaseCapabilityImplementation,
IntersectService,
Expand All @@ -9,6 +10,7 @@
intersect_message,
intersect_status,
)
from intersect_sdk.config.shared import BrokerConfig

logging.basicConfig(level=logging.INFO)
logging.getLogger('pika').setLevel(logging.WARNING)
Expand Down Expand Up @@ -45,16 +47,19 @@ def say_hello_to_name(self, name: str) -> str:

In most cases, everything under from_config_file should come from a configuration file, command line arguments, or environment variables.
"""
from_config_file = {
'brokers': [
{
'username': 'intersect_username',
'password': 'intersect_password',
'port': 5672,
'protocol': 'amqp0.9.1',
},
],
}
broker_configs = [
{'host': 'localhost', 'port': 5672},
]

brokers = [
ControlPlaneConfig(
protocol='amqp0.9.1',
username='intersect_username',
password='intersect_password',
brokers=[BrokerConfig(**broker) for broker in broker_configs],
)
]

config = IntersectServiceConfig(
hierarchy=HierarchyConfig(
organization='hello-organization',
Expand All @@ -63,7 +68,7 @@ def say_hello_to_name(self, name: str) -> str:
subsystem='hello-subsystem',
service='hello-service',
),
**from_config_file,
brokers=brokers,
)

"""
Expand Down
26 changes: 15 additions & 11 deletions examples/1_hello_world_events/hello_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,14 @@

from intersect_sdk import (
INTERSECT_JSON_VALUE,
ControlPlaneConfig,
IntersectClient,
IntersectClientCallback,
IntersectClientConfig,
IntersectDirectMessageParams,
default_intersect_lifecycle_loop,
)
from intersect_sdk.config.shared import BrokerConfig

logging.basicConfig(level=logging.INFO)

Expand Down Expand Up @@ -63,16 +65,18 @@ def simple_event_callback(

In most cases, everything under from_config_file should come from a configuration file, command line arguments, or environment variables.
"""
from_config_file = {
'brokers': [
{
'username': 'intersect_username',
'password': 'intersect_password',
'port': 1883,
'protocol': 'mqtt3.1.1',
},
],
}
broker_configs = [
{'host': 'localhost', 'port': 1883},
]

brokers = [
ControlPlaneConfig(
protocol='mqtt3.1.1',
username='intersect_username',
password='intersect_password',
brokers=[BrokerConfig(**broker) for broker in broker_configs],
)
]
"""
step two: construct the initial messages you want to send. In this case we will only send a single starting message.

Expand All @@ -99,7 +103,7 @@ def simple_event_callback(
'hello-organization.hello-facility.hello-system.hello-subsystem.hello-service'
],
),
**from_config_file,
brokers=brokers,
)

"""
Expand Down
26 changes: 15 additions & 11 deletions examples/1_hello_world_events/hello_service.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import logging

from intersect_sdk import (
ControlPlaneConfig,
HierarchyConfig,
IntersectBaseCapabilityImplementation,
IntersectEventDefinition,
Expand All @@ -10,6 +11,7 @@
intersect_message,
intersect_status,
)
from intersect_sdk.config.shared import BrokerConfig

logging.basicConfig(level=logging.INFO)
logger = logging.getLogger(__name__)
Expand Down Expand Up @@ -48,16 +50,18 @@ def say_hello_to_name(self, name: str) -> str:

In most cases, everything under from_config_file should come from a configuration file, command line arguments, or environment variables.
"""
from_config_file = {
'brokers': [
{
'username': 'intersect_username',
'password': 'intersect_password',
'port': 1883,
'protocol': 'mqtt3.1.1',
},
],
}
broker_configs = [
{'host': 'localhost', 'port': 1883},
]

brokers = [
ControlPlaneConfig(
protocol='mqtt3.1.1',
username='intersect_username',
password='intersect_password',
brokers=[BrokerConfig(**broker) for broker in broker_configs],
)
]
config = IntersectServiceConfig(
hierarchy=HierarchyConfig(
organization='hello-organization',
Expand All @@ -66,7 +70,7 @@ def say_hello_to_name(self, name: str) -> str:
subsystem='hello-subsystem',
service='hello-service',
),
**from_config_file,
brokers=brokers,
)

"""
Expand Down
27 changes: 18 additions & 9 deletions examples/1_hello_world_minio/hello_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,15 @@

from intersect_sdk import (
INTERSECT_JSON_VALUE,
ControlPlaneConfig,
IntersectClient,
IntersectClientCallback,
IntersectClientConfig,
IntersectDataHandler,
IntersectDirectMessageParams,
default_intersect_lifecycle_loop,
)
from intersect_sdk.config.shared import BrokerConfig

logging.basicConfig(level=logging.INFO)

Expand Down Expand Up @@ -43,6 +45,20 @@ def simple_client_callback(

In most cases, everything under from_config_file should come from a configuration file, command line arguments, or environment variables.
"""

broker_configs = [
{'host': 'localhost', 'port': 1883},
]

brokers = [
ControlPlaneConfig(
protocol='mqtt3.1.1',
username='intersect_username',
password='intersect_password',
brokers=[BrokerConfig(**broker) for broker in broker_configs],
)
]

from_config_file = {
# NOTE: for this example, you will need a MINIO instance configured at this stage.
'data_stores': {
Expand All @@ -53,15 +69,7 @@ def simple_client_callback(
'port': 9000,
},
],
},
'brokers': [
{
'username': 'intersect_username',
'password': 'intersect_password',
'port': 1883,
'protocol': 'mqtt3.1.1',
},
],
}
}
"""
step two: construct the initial messages you want to send. In this case we will only send a single starting message.
Expand All @@ -86,6 +94,7 @@ def simple_client_callback(
]
config = IntersectClientConfig(
initial_message_event_config=IntersectClientCallback(messages_to_send=initial_messages),
brokers=brokers,
**from_config_file,
)

Expand Down
Loading