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

[Atom] Create Atom Plugin #93

Open
wants to merge 9 commits into
base: master
Choose a base branch
from
Open

[Atom] Create Atom Plugin #93

wants to merge 9 commits into from

Conversation

rageandqq
Copy link
Member

Created an atom plugin! Woo! Follows the protocol defined in the Wiki.

Added a similar dev setup script with symlinks. You will however need to install the required node modules before this will work.

Granted, this isn't launch blocking, so don't feel rushed to review.

Will add screenshots/screencasts here as well.

#30

@rageandqq rageandqq self-assigned this Feb 16, 2018
@@ -0,0 +1,15 @@
module.exports = {
Copy link
Member

@jamiboym jamiboym Feb 16, 2018

Choose a reason for hiding this comment

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

I think we should keep the styling for all our .js files the same and all our .py files the same, and so on - I believe the crdt styling doesn't change any rules from airbnb's default

Copy link
Member Author

Choose a reason for hiding this comment

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

Sure. Some of these should be here, like the globals, since they are atom specific.
Others like the rules can be moved to a global config if you're okay with that:

  • no-underscore-dangle means you can't have members like this._privateMember which I am against since thats a convention we follow in the python library as well and is generally well accepted javascript
  • no-plusplus seems reasonable to have, value++ is common and unless you have a good reason why we shouldn't allow it I don't see why not
  • 'no-linely-ifit should be okay to have anifinside anelse` statement. I think the linter is giving a false positive for me, but even if it isn't Personally I don't see why not.

I'm okay for removing any of these configs. as long as they are given/within reason. But I agree that they should be kept consistent, and we should leave them configs in the tandem root.

Copy link
Member

Choose a reason for hiding this comment

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

an if inside an else is just an else if isn't it? For the others, sure -- but I think we should move the.eslintrc in the Tandem root folder and symlink it to both the crdt folder and here

_shutDownAgent() {
this._subscriptions.dispose();
this._processingMessage = false;
this._agent.kill('SIGKILL');
Copy link
Member

Choose a reason for hiding this comment

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

I think we should default to SIGTERM here so that the agent can shut down gracefully. If we use SIGKILL the agent won't get a chance to inform the other peers that it's leaving the session.

Copy link
Member Author

Choose a reason for hiding this comment

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

👍 hopefully this still kills the agent - I recall having issues using SIGTERM which is why I switched to SIGKILL.

_readAgent(data) {
// Prevent future 'data' callbacks from being invoked until stream is
// unpaused
this._agent.stdout.pause();
Copy link
Member

Choose a reason for hiding this comment

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

Does not having this cause problems? JS should be single threaded so if you're running the code here other callbacks can't be invoked.

Copy link
Member Author

Choose a reason for hiding this comment

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

JS is single threaded, but can't the execution jump between two instances of the callback? There's no guarantee that the entirety of readAgent will be invoked before another callback is handled (if, say, two chunks of data are submitted at once) is there? If there is, then this can be removed.

Copy link
Member

Choose a reason for hiding this comment

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

I doubt it would switch because then you'd be introducing concurrency, ultimately meaning you'd need concurrency control to protect your data.

According to the MDN, the event loop runs functions to completion (i.e. no preemption)
https://developer.mozilla.org/en-US/docs/Web/JavaScript/EventLoop#Event_loop

console.log('Inavlid message. Expected WriteRequest.');
} else {
// Prevent non-Apply Patches messages from being processed
this._processingMessage = true;
Copy link
Member

Choose a reason for hiding this comment

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

Even if we don't send NewPatches while this flag is up the user can still edit the text buffer, which can cause inconsistencies. Is there no other way around this?

In the worst case I nothing can be done I think we should actually go as far as undoing the user's change if there is one while this flag is up. It should be rare, but if an inconsistency actually does happen it may crash the CRDT.

Copy link
Member Author

Choose a reason for hiding this comment

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

There's no way to stop the user from editing the buffer. We'll have to undo the change.

const message = m.deserialize(data);

if (!this._processingMessage) {
if (!(message instanceof m.WriteRequest)) {
Copy link
Member

Choose a reason for hiding this comment

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

With the hole punching changes the agent may also send the SessionInfo message. This is typically only sent once though.

// Prevent future 'data' callbacks from being invoked until stream is
// unpaused
this._agent.stdout.pause();
const message = m.deserialize(data);
Copy link
Member

Choose a reason for hiding this comment

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

This assumes that a data event contains a complete message. I'm not sure if that's guaranteed by node, especially if it's a large message. I think to be safe we should be looking for the newline character to know if we've reached a message boundary. We do something similar when processing messages on the CRDT process.

https://github.com/geoffxy/tandem/blob/master/crdt/io/index.js#L7

Copy link
Member Author

Choose a reason for hiding this comment

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

Faire enough.

const getStringPort = () =>
String(random(60600, 62600));

const createPatches = event =>
Copy link
Member

Choose a reason for hiding this comment

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

How does teletype handle this? If possible we want to avoid having to apply changes in two steps since we can get weird interleaving.

"tandem:leave-session"
]
},
"repository": "https://github.com/geoffxy/tandem",
Copy link
Member

Choose a reason for hiding this comment

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

If we end up open sourcing this I think we should move the repo under typeintandem. I think we should just omit this for now.

Copy link
Member Author

Choose a reason for hiding this comment

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

Agreed, I'm fine with that.

]
},
"repository": "https://github.com/geoffxy/tandem",
"license": "MIT",
Copy link
Member

Choose a reason for hiding this comment

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

Maybe also omit this for now until we decide if/how we plan to open source and maintain/support this after March 14.

cc @jamiboym

Copy link
Member

Choose a reason for hiding this comment

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

These two don't really matter until we actually open source it - I guess it would be better to remove it for now so its not in our commit history. (But I think we can chose how far back our commit history we can make public anyways?)

Copy link
Member Author

Choose a reason for hiding this comment

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

Sgtm


const spawnAgent = (args) => {
const dirname = path.resolve(__dirname);
const filename = path.join(dirname, '../agent/main.py');
Copy link
Member

Choose a reason for hiding this comment

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

Since path.join is already being used, I think we should use

const filename = path.join(dirname, '..', 'agent', 'main.py');

to keep it platform agnostic.

Copy link
Member Author

Choose a reason for hiding this comment

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

Good point.

@rageandqq
Copy link
Member Author

rageandqq commented Feb 28, 2018

This is now additionally out of date. Changes similar to those in #97 will need to be added to support the hole punching updates.

@todrobbins
Copy link

Excited to see this piece finished! Thanks for the hard work!

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.

None yet

4 participants