-
Notifications
You must be signed in to change notification settings - Fork 153
Conversation
Hi @MrMeemus, I'm your friendly neighborhood Microsoft Pull Request Bot (You can call me MSBOT). Thanks for your contribution!
TTYL, MSBOT; |
@pensivebrian is added to the review. #Closed |
@abhisheksinha89 is added to the review. #Closed |
src/json-rpc/json/rpc/json_rpc.py
Outdated
json_content = json.dumps(content_body) | ||
header = self.HEADER.format(str(len(json_content))) | ||
|
||
self.stream.write(header.encode("ascii")) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"ascii" [](start = 40, length = 7)
Will change to single quotes to be consistent through out the file #Resolved
src/json-rpc/json/rpc/json_rpc.py
Outdated
|
||
def read_response(self): | ||
# Using a mutable list to hold the value since a immutable string passed by reference won't change the value | ||
message_content = [""] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removing notion of a message to just headers and body content. i.e try_read_message_headers -> try_read_headers #Resolved
…t; removing notion of a message since that is client/server specific
src/json-rpc/json/rpc/json_rpc.py
Outdated
from io import BytesIO | ||
import json | ||
|
||
class JSON_RPC_Writer(object): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
JSON_RPC_Writer [](start = 6, length = 15)
Class names should use the CapWords convention. https://www.python.org/dev/peps/pep-0008/#class-names #Resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice work! Looking forward to using these classes.
src/json-rpc/json/rpc/json_rpc.py
Outdated
|
||
self.stream.write(header.encode("ascii")) | ||
self.stream.write(json_content.encode(self.encoding)) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we add a flush after the last write? #Resolved
src/json-rpc/json/rpc/json_rpc.py
Outdated
|
||
class JSON_RPC_Reader(object): | ||
# \r\n | ||
CR = 13 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think a '\r' is more clear - can we use that instead? #Pending
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It would require us to slice the byte array to decode in a contiguous array since each byte is a int and doesn't support decode;i.e buffer[scanoffset:scanoffset+3].decode('ascii') == '\r\n\r\n' which I think could introduce unecessary checks like if the offset + 3 exceeds the boundaries. Checking byte by it's numeric value looks cleaner IMO. Let me know what you think.
In reply to: 102364905 [](ancestors = 102364905)
src/json-rpc/json/rpc/json_rpc.py
Outdated
class JSON_RPC_Reader(object): | ||
# \r\n | ||
CR = 13 | ||
LF = 10 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same thing, I think a '\n' is more clear than the numeric constant. #ByDesign
src/json-rpc/json/rpc/json_rpc.py
Outdated
message_content = [""] | ||
while (self.read_next_chunk()): | ||
# If we can't read a header, read the next chunk | ||
if (self.read_state == "Header" and not self.try_read_message_headers()): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is the == "Header" case sensitive? #Pending
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Right now it is, The plan is to add Enums to contain the state. Which should come out in the next iteration
In reply to: 102365093 [](ancestors = 102365093)
src/json-rpc/json/rpc/json_rpc.py
Outdated
if (self.read_state == "Header" and not self.try_read_message_headers()): | ||
continue | ||
# If we read the header, try the content. If that fails, read the next chunk | ||
if (self.read_state == "Content" and not self.try_read_message_content(message_content)): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Again, is == "Content" case sensitive? #Pending
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
from io import BytesIO | ||
import unittest | ||
|
||
class JSON_RPC_Test(unittest.TestCase): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you add some case-sensitivity tests? #Resolved
src/json-rpc/json/rpc/json_rpc.py
Outdated
if encoding is None: | ||
self.encoding = 'UTF-8' | ||
|
||
def send_request(self, method, params, id): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Default id = null? #Resolved
src/json-rpc/json/rpc/json_rpc.py
Outdated
@@ -0,0 +1,175 @@ | |||
# -------------------------------------------------------------------------------------------- |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we move this into a src/common folder? Also, do we really need 'json/rpc' directories? We only have a few files, so all of them in the json-rpc seems sensible. #Resolved
@@ -0,0 +1,106 @@ | |||
# -------------------------------------------------------------------------------------------- |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you move this into a tests sub-folder from the code? #Resolved
…of json rpc lib, added skeleton folder structure for future cli tools, added test setup, added dev set up files for installing dependencies and running tests
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice! Only minor changes.
src/common/README.md
Outdated
@@ -0,0 +1,2 @@ | |||
Microsoft XPlat Cli common module |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: CLI #Resolved
src/common/json_rpc.py
Outdated
@@ -4,9 +4,18 @@ | |||
# -------------------------------------------------------------------------------------------- |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: can use use single quotes in this file instead on double quotes - seems to be the Python convention. #Resolved
@@ -0,0 +1,3 @@ | |||
enum34==1.1.6 | |||
pip==9.0.1 | |||
setuptools==30.4.0 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is 'setuptools' used for? #ByDesign
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
setuptools builds the package so we can use setup.py
In reply to: 103035860 [](ancestors = 103035860)
author='Microsoft Corporation', | ||
author_email='ssdteng@microsoft.com', | ||
url='https://github.com/Microsoft/sql-xplat-cli/', | ||
) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add a newline to get rid of the warning? #Resolved
…tory which was not tracked
Merging json rpc library with tests, dev set up, and basic folder structure. |
We have a 2 threads: Thread #1 runs in a loop polling the response queue Thread #2 runs in a loop decoding responses from the sqltoolsservice over stdout and posting them to the response queue Since thread #1 doesn't sleep, it's takes 100% CPU. In addition, running python 2.7 on windows, #2 doesn’t preempt the CPU due to #1 taking all of the CPU cycles, so no response is processed. Fix is simple – thread #1 needs to sleep so thread #2 can get scheduled and get it’s work done.
Fix perf issue where main event loop takes 100% of CPU We have a 2 threads: Thread #1 runs in a loop polling the response queue Thread #2 runs in a loop decoding responses from the sqltoolsservice over stdout and posting them to the response queue Since thread #1 doesn't sleep, it's takes 100% CPU. In addition, running python 2.7 on windows, #2 doesn’t preempt the CPU due to #1 taking all of the CPU cycles, so no response is processed. Fix is simple – thread #1 needs to sleep so thread #2 can get scheduled and get it’s work done.
* Use SqlToolsService built on .NET Core 2.0 and a build script updates (#131) * Bump version to 1.0.0a19 * Use .NET Core 2.0 RTM built sqltoolsservice * Add build script to upload to azure blob storage * Upgrade to VS 2017 * Remove 3.3 as supported Python version * Fix perf issue where main event loop takes 100% of CPU (#132) Fix perf issue where main event loop takes 100% of CPU We have a 2 threads: Thread #1 runs in a loop polling the response queue Thread #2 runs in a loop decoding responses from the sqltoolsservice over stdout and posting them to the response queue Since thread #1 doesn't sleep, it's takes 100% CPU. In addition, running python 2.7 on windows, #2 doesn’t preempt the CPU due to #1 taking all of the CPU cycles, so no response is processed. Fix is simple – thread #1 needs to sleep so thread #2 can get scheduled and get it’s work done. * Refine event loop perf fix in main.py Refine event loop perf fix in main.py * Fixing regular expression Previous regex would result in release:a1 and release_version: 12. Modified the regex for part Release to only pick up lower case letters. * Adding missing forward slash on test pypi url * fixing typos/grammar (#138) fixing typos/grammar. * Updating to release version 1.0.0a20.
* Use SqlToolsService built on .NET Core 2.0 and a build script updates (#131) * Bump version to 1.0.0a19 * Use .NET Core 2.0 RTM built sqltoolsservice * Add build script to upload to azure blob storage * Upgrade to VS 2017 * Remove 3.3 as supported Python version * Fix perf issue where main event loop takes 100% of CPU (#132) Fix perf issue where main event loop takes 100% of CPU We have a 2 threads: Thread #1 runs in a loop polling the response queue Thread #2 runs in a loop decoding responses from the sqltoolsservice over stdout and posting them to the response queue Since thread #1 doesn't sleep, it's takes 100% CPU. In addition, running python 2.7 on windows, #2 doesn’t preempt the CPU due to #1 taking all of the CPU cycles, so no response is processed. Fix is simple – thread #1 needs to sleep so thread #2 can get scheduled and get it’s work done. * Refine event loop perf fix in main.py Refine event loop perf fix in main.py * Fixing regular expression Previous regex would result in release:a1 and release_version: 12. Modified the regex for part Release to only pick up lower case letters. * Adding missing forward slash on test pypi url * fixing typos/grammar (#138) fixing typos/grammar. * Updating to release version 1.0.0a20. * Create doc for official msft docs page * Updated documentation page with usage_guide * Added link to download adventureworks * Updated with sqlcmd usage * Added in run and cloud shell support * Update/consolidate linux install (#153) * universal linux wheel gen and setup update. * Updating version cfg. * Updating sqltoolsservice container. * Updating spacing for flake8. * Updating team email. (#154)
* Merge release 1.0.0a21 (#155) * Use SqlToolsService built on .NET Core 2.0 and a build script updates (#131) * Bump version to 1.0.0a19 * Use .NET Core 2.0 RTM built sqltoolsservice * Add build script to upload to azure blob storage * Upgrade to VS 2017 * Remove 3.3 as supported Python version * Fix perf issue where main event loop takes 100% of CPU (#132) Fix perf issue where main event loop takes 100% of CPU We have a 2 threads: Thread #1 runs in a loop polling the response queue Thread #2 runs in a loop decoding responses from the sqltoolsservice over stdout and posting them to the response queue Since thread #1 doesn't sleep, it's takes 100% CPU. In addition, running python 2.7 on windows, #2 doesn’t preempt the CPU due to #1 taking all of the CPU cycles, so no response is processed. Fix is simple – thread #1 needs to sleep so thread #2 can get scheduled and get it’s work done. * Refine event loop perf fix in main.py Refine event loop perf fix in main.py * Fixing regular expression Previous regex would result in release:a1 and release_version: 12. Modified the regex for part Release to only pick up lower case letters. * Adding missing forward slash on test pypi url * fixing typos/grammar (#138) fixing typos/grammar. * Updating to release version 1.0.0a20. * Create doc for official msft docs page * Updated documentation page with usage_guide * Added link to download adventureworks * Updated with sqlcmd usage * Added in run and cloud shell support * Update/consolidate linux install (#153) * universal linux wheel gen and setup update. * Updating version cfg. * Updating sqltoolsservice container. * Updating spacing for flake8. * Updating team email. (#154) * Updating mssqltoolsservice to be integrated as a package of mssqlscripter. * Updating sqltoolsservice to be loaded from the repro instead of storage account. * Fix index file generation for daily storage account. * Fixing manylinux1 tag. * Updating platform tag for win x64. * Renaming sqltoolsservice win x64 folder. * Adding platform tags for win_amd64, manylinux1_x86_64, manylinux1_i686. * version bumping to 1.0.0a22. * Flake8 format fixes. * Erroring out when build receives invalid flag.
* Use SqlToolsService built on .NET Core 2.0 and a build script updates (#131) * Bump version to 1.0.0a19 * Use .NET Core 2.0 RTM built sqltoolsservice * Add build script to upload to azure blob storage * Upgrade to VS 2017 * Remove 3.3 as supported Python version * Fix perf issue where main event loop takes 100% of CPU (#132) Fix perf issue where main event loop takes 100% of CPU We have a 2 threads: Thread #1 runs in a loop polling the response queue Thread #2 runs in a loop decoding responses from the sqltoolsservice over stdout and posting them to the response queue Since thread #1 doesn't sleep, it's takes 100% CPU. In addition, running python 2.7 on windows, #2 doesn’t preempt the CPU due to #1 taking all of the CPU cycles, so no response is processed. Fix is simple – thread #1 needs to sleep so thread #2 can get scheduled and get it’s work done. * Refine event loop perf fix in main.py Refine event loop perf fix in main.py * Fixing regular expression Previous regex would result in release:a1 and release_version: 12. Modified the regex for part Release to only pick up lower case letters. * Adding missing forward slash on test pypi url * fixing typos/grammar (#138) fixing typos/grammar. * Updating to release version 1.0.0a20. * Create doc for official msft docs page * Updated documentation page with usage_guide * Added link to download adventureworks * Updated with sqlcmd usage * Added in run and cloud shell support * Update/consolidate linux install (#153) * universal linux wheel gen and setup update. * Updating version cfg. * Updating sqltoolsservice container. * Updating spacing for flake8. * Updating team email. (#154) * Fixing resource warning for sqltoolsservice (#158) * Fixing resource warning for sqltoolsservice by closing stdout after killing process. * Shortening sleep time during shutdown. * Fixing missing bracket. * Updating doc's after repro rename (#160) * Updating files after repro rename. * Fixing flake8 issues. * Ron/platform wheels support (#161) * Merge release 1.0.0a21 (#155) * Use SqlToolsService built on .NET Core 2.0 and a build script updates (#131) * Bump version to 1.0.0a19 * Use .NET Core 2.0 RTM built sqltoolsservice * Add build script to upload to azure blob storage * Upgrade to VS 2017 * Remove 3.3 as supported Python version * Fix perf issue where main event loop takes 100% of CPU (#132) Fix perf issue where main event loop takes 100% of CPU We have a 2 threads: Thread #1 runs in a loop polling the response queue Thread #2 runs in a loop decoding responses from the sqltoolsservice over stdout and posting them to the response queue Since thread #1 doesn't sleep, it's takes 100% CPU. In addition, running python 2.7 on windows, #2 doesn’t preempt the CPU due to #1 taking all of the CPU cycles, so no response is processed. Fix is simple – thread #1 needs to sleep so thread #2 can get scheduled and get it’s work done. * Refine event loop perf fix in main.py Refine event loop perf fix in main.py * Fixing regular expression Previous regex would result in release:a1 and release_version: 12. Modified the regex for part Release to only pick up lower case letters. * Adding missing forward slash on test pypi url * fixing typos/grammar (#138) fixing typos/grammar. * Updating to release version 1.0.0a20. * Create doc for official msft docs page * Updated documentation page with usage_guide * Added link to download adventureworks * Updated with sqlcmd usage * Added in run and cloud shell support * Update/consolidate linux install (#153) * universal linux wheel gen and setup update. * Updating version cfg. * Updating sqltoolsservice container. * Updating spacing for flake8. * Updating team email. (#154) * Updating mssqltoolsservice to be integrated as a package of mssqlscripter. * Updating sqltoolsservice to be loaded from the repro instead of storage account. * Fix index file generation for daily storage account. * Fixing manylinux1 tag. * Updating platform tag for win x64. * Renaming sqltoolsservice win x64 folder. * Adding platform tags for win_amd64, manylinux1_x86_64, manylinux1_i686. * version bumping to 1.0.0a22. * Flake8 format fixes. * Erroring out when build receives invalid flag. * Fixing tag for win64 * Update libunwind8 install for CentOS * Ron/sqltoolsservice update (#163) * Updating sqltoolsservice with self contained version. * Refreshing sqltoolsservice again. * Making mssql-scripter executable and adding null checks in main.py * Adding clean up step to remove build directory after each build. * Fixing path for build directory. * Removing 'pypi' from upload step. * Flake 8 extra line fix.
Adding the json rpc library support module. This module should support basic request/response scenario with any bytestream. Not sure about the file structure, priority is getting the source out and reviewed.