Skip to content

Conversation

@daminichopra
Copy link
Contributor

Proposed changes

Does changes as per references
Fix for Issue

Types of changes

What types of changes does your code introduce to the project: Put
an x in the boxes that apply

  • [ x ] Bugfix (non-breaking change which fixes an issue)
  • [ x ] New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing
    functionality to not work as expected)

Checklist

Put an x in the boxes that apply. You can also fill these out after
creating the PR. If you're unsure about any of them, don't hesitate to
ask. We're here to help! This is simply a reminder of what we are going
to look for before merging your code.

  • [ x ] I have read the CONTRIBUTING doc
  • [ x ] I have signed the CLA
  • I have added tests that prove my fix is effective or that my
    feature works
  • I have added necessary documentation (if appropriate)
  • Any dependent changes have been merged and published in
    downstream modules

Further comments

  • Replaced "borg" connection used in file connection_manager.py with CrateDB's SQLAlchemy dialect

  • Also, took references from discussion

  • used create_engine connection.

@github-actions
Copy link
Contributor

github-actions bot commented Dec 14, 2021

CLA Assistant Lite bot All contributors have signed the CLA ✍️

self.port = port
self.db_name = db_name

def __enter__(self):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i don't think you need to change this method, the idea should be to replace the connection manager with sqlalchemy "create engine", but without changing interfaces

def __init__(self, host, port=4200, db_name="ngsi-tsdb"):
super(CrateTranslator, self).__init__(host, port, db_name)
def __init__(self, connection, query , host, port=4200, db_name="ngsi-tsdb"):
super(CrateTranslator, self).__init__(host, connection, query , port, db_name)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

see comment above


def setup(self):
def setup(self, connection, query):
url = "{}:{}".format(self.host, self.port)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

so, in here, you would use create_engine to get your connection using the proper parameters

exc_info=True)


class QueryCacheManager(Borg):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i think you can keep the borg here

def __init__(self):
super(QueryCacheManager, self).__init__()
def __init__(self, connection, query):
super(QueryCacheManager, self ).__init__( connection, query)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

and leave this unchanged

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

updated as suggested

@@ -1,25 +1,67 @@
class Borg:
_shared_state = {}
from crate import client
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you should leave this class unchanged, because as said the idea is to replace directly in setup, secondly, you would need to proceed, so to say, in parallel and support both crate and timescale, easy if you keep this unchanged, if you touch this, you would need to adjust also timescale code, since it uses this code

def setup(self):
def setup(self, connection, query):
url = "{}:{}".format(self.host, self.port)
self.ccm = ConnectionManager()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

here could be an example (but don't take granted it works ;) ):

url = "crate://{}:{}".format(self.host, self.port)
        self.engine = sa.create_engine(url, connect_args={"pool_size": 10})
        self.connection = self.engine.connect()

of course it could be possible to create the two connection pools (the one for crate and the one for timescale), at the app start, and pass them, this would be probably the best option from a tech point, but you would need probably to change quite some code...

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

updated as suggested

Copy link
Contributor Author

@daminichopra daminichopra Jan 24, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@chicco785 @c0c0n3 , I have PR as suggested but some test are failing which are not shown up as in my local env.

@daminichopra daminichopra marked this pull request as ready for review December 15, 2021 06:58
@daminichopra daminichopra marked this pull request as draft December 19, 2021 16:54
@daminichopra daminichopra marked this pull request as ready for review January 21, 2022 04:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants