Skip to content
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

File connector and modified file messenger #2

Closed
wants to merge 11 commits into from

Conversation

CarltonS13
Copy link
Contributor

Implemented a file connector based off the local connector to include functionality for S3 via Smart open.
Modified the file messenger to use this new file connector.

# todo instead of write use put and pass in path
bytes_written = self.logfiles[endpoint].put(
message + '\n'.encode('utf-8'), append=append)
if bytes_written is True:
Copy link
Contributor

Choose a reason for hiding this comment

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

Connector.put just returns a boolean, so bytes_written is a misleading variable name now. (I guess it wasnt fully clear before either, unless you know that IO.write returns the number of bytes.) Maybe just call it success ?

return False

def get_last_id(self):
pass
Copy link
Contributor

Choose a reason for hiding this comment

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

Remove.

log.warning(e)


class Connector(object):
Copy link
Contributor

Choose a reason for hiding this comment

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

Should inherit from connectors.base.Connector .

Copy link
Contributor Author

Choose a reason for hiding this comment

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

connectors.base.Connector is not functional currently because it relies on parsers which have not yet been implemented

"""
if sep == '':
raise Exception("Need seperator to parse last_id from file names")

Copy link
Contributor

Choose a reason for hiding this comment

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

The use of the id in the filename is just a convention in the pipe application. I think we just need to get the last file by date and the last line of that file and parse it, so all we have to pass in here is the bucket, path prefix, and name of the field storing the id value, which should of course default to "id".


log = logger.get()


Copy link
Contributor

Choose a reason for hiding this comment

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

Why so much duplication in this file? I'm not sure we need it at all. At most, it could just be Notifier = cranial.messaging.file.Notifier, right?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The thing is, looking through the code, cranial.messaging.file.Notifier has a lot of safeties and checks based off the os package. These checks fail for s3. I didn't want to take them out because I thought they might be useful.

@matt2000
Copy link
Contributor

matt2000 commented Jul 7, 2019

Please merge master into you branch & resolve conflicts.

CarltonS13 and others added 6 commits July 8, 2019 11:56
Modified connectors.file to better get prefixes from paths with files
Removed unnecessary imports
Renamed bytes modified to success to make more understandable
Updated get last_id method in cranial.messaging.file
are not overwritten by defaults.
Added functionality for serdes to be passed to s3 notifier
Added warning for deprecated s3 connector module
added closed attribute to file connector
@matt2000
Copy link
Contributor

Closing in favor of PR #5

@matt2000 matt2000 closed this Jul 23, 2019
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