@@ -24,7 +24,7 @@ All the cloud connections are initialized with `initialize` function of core whi
2424Eg.
2525``` python
2626from python_ms_core import Core
27- Core.initialize( )
27+ core = Core() or Core( config = ' Local ' )
2828```
2929The method analyzes the ` .env ` variables and does a health check on what components are available
3030
@@ -56,12 +56,13 @@ This file will have to be generated or shared offline as per the developer requi
5656Offers helper classes to help log the information. It is also used to record the audit messages
5757as well as the analytics information required.
5858
59- Use ` Core .get_logger()`
59+ Use ` core .get_logger()`
6060Eg.
6161``` python
6262from python_ms_core import Core
6363
64- logger = Core.get_logger()
64+ core = Core()
65+ logger = core.get_logger()
6566
6667# Record a metric
6768logger.record_metric(name = ' test' , value = ' test' ) # Metric and value
7475``` python
7576from python_ms_core import Core
7677
77- logger = Core.get_logger()
78+ core = Core()
79+ logger = core.get_logger()
7880
7981# Record a metric
8082logger.debug(' Debug Message' )
@@ -102,15 +104,12 @@ The configuration required by Queue and Topic is similar and will be handled via
102104
103105Topic can be accessed by the core method ` get_topic ` . This method takes two parameters
1041061 . topic name (required)
105- 2 . callback function where messages will be received
106107
107108``` python
108109from python_ms_core import Core
109110
110- def callback (instance ):
111- print (instance.get_messages())
112-
113- topic = Core.get_topic(topic_name = ' topicName' , callback = callback)
111+ core = Core()
112+ topic = core.get_topic(topic_name = ' topicName' )
114113
115114```
116115
@@ -121,7 +120,8 @@ Once the topic object is got, use `publish` method to publish the message to top
121120from python_ms_core import Core
122121from python_ms_core.core.queue.models.queue_message import QueueMessage
123122
124- topic = Core.get_topic(topic_name = ' topicName' )
123+ core = Core()
124+ topic = core.get_topic(topic_name = ' topicName' )
125125topic.publish(QueueMessage.data_from(
126126 {
127127 ' message' : ' Test message'
@@ -139,18 +139,26 @@ It takes one parameter
139139``` python
140140from python_ms_core import Core
141141
142- topic = Core.get_topic(topic_name = ' topicName' )
143- msg = topic.subscribe(subscription = ' subscriptionName' )
144- print (msg)
142+ core = Core()
143+ topic_object = topic = Core.get_topic(topic_name = ' topicName' )
144+
145+ def process (message ):
146+ print (f ' Message Received: { message} ' )
147+
148+ try :
149+ topic_object.subscribe(subscription = ' subscriptionName' )
150+ except Exception as e:
151+ print (e)
145152```
146153
147154### Storage
148155For all the azure blobs and other storages, storage components will offer simple ways to upload/download and read the existing data.
149156``` python
150157from python_ms_core import Core
151158
159+ core = Core()
152160# Create storage client
153- azure_client = Core .get_storage_client()
161+ azure_client = core .get_storage_client()
154162
155163# Get a container in the storage client
156164container = azure_client.get_container(container_name = ' tdei-storage-test' )
@@ -168,7 +176,8 @@ File upload is done only through read stream.
168176from python_ms_core import Core
169177from io import BytesIO, StringIO
170178
171- azure_client = Core.get_storage_client()
179+ core = Core()
180+ azure_client = core.get_storage_client()
172181container = azure_client.get_container(container_name = ' tdei-storage-test' )
173182# Create an instance of `AzureFileEntity` with name and mime-type
174183txt = ' foo\n bar\n baz'
0 commit comments