Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
d36fcc3
wip: rework clients to support async
jyecusch Jun 26, 2021
3c4f0e2
chore: ignore autogenerated packages
jyecusch Jun 26, 2021
5efe684
wip: fix Struct to/from dict conversion
jyecusch Jun 28, 2021
343290c
test(QueueClient): update tests for new api and async
jyecusch Jun 28, 2021
15db383
wip: update storage api and tests
jyecusch Jun 28, 2021
616cfea
wip: WIP python gRPC FaaS implementation.
tjholm Jun 13, 2021
5e5baf9
wip: Working Python gRPC FaaS PoC.
tjholm Jun 14, 2021
2d4e23d
chore: ignore asyncio license
jyecusch Jun 30, 2021
522ec95
feat: port faas.start to bi-di streaming with membrane
jyecusch Jun 30, 2021
2862133
wip: handle bytes responses
jyecusch Jul 2, 2021
304f696
wip: add json content type to json responses
jyecusch Jul 6, 2021
2242204
wip: include queue_stub in receieved tasks
jyecusch Jul 6, 2021
fd3faa5
wip: include queue name in received tasks
jyecusch Jul 6, 2021
f4810b8
wip: add queue tests and update client names
jyecusch Jul 7, 2021
807e9a8
wip: fix eventing rename
jyecusch Jul 7, 2021
4b11403
wip: improve support None payloads
jyecusch Jul 7, 2021
3b7a709
test: increase coverage of api classes
jyecusch Jul 7, 2021
035449f
fix: raise when trying to send an empty batch of tasks
jyecusch Jul 7, 2021
0a4fb1a
wip: handle connection refused error
jyecusch Jul 8, 2021
9094d1b
fix: fix context type detection
jyecusch Jul 8, 2021
ad05629
test: add faas tests
jyecusch Jul 8, 2021
7ed1924
fix: close channels when clients are destroyed
jyecusch Jul 8, 2021
45c28eb
feat: add documents client
jyecusch Jul 12, 2021
5bfd605
chore: point contracts submodule to main
jyecusch Jul 12, 2021
9a88953
wip: add query method to collections
jyecusch Jul 12, 2021
159258f
feat: remove kv client
jyecusch Jul 12, 2021
b972650
wip: enhance where clause handling for queries
jyecusch Jul 13, 2021
7c12407
docs: add where usage docs
jyecusch Jul 13, 2021
ca6b3f0
fix: update to new grpc service suffixes
jyecusch Jul 15, 2021
11b65dc
fix: fix query equals operator value
jyecusch Jul 16, 2021
6aaec91
fix: full doc responses
jyecusch Jul 19, 2021
d213c75
wip: separate task and received task classes
jyecusch Jul 20, 2021
86d57e3
fix: make max sub-collection depth configurable
jyecusch Jul 20, 2021
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
# Protoc Output Files
*_pb2.py
*_pb2_grpc.py
nitric/proto/

.idea/

Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,5 +41,5 @@ pip3 install nitric

```python
# import classes/modules as required
from nitric.api import EventClient, KeyValueClient
from nitric.api import Events, KeyValueClient
```
2 changes: 1 addition & 1 deletion contracts
370 changes: 370 additions & 0 deletions docs/nitric/api/events.html

Large diffs are not rendered by default.

660 changes: 220 additions & 440 deletions docs/nitric/api/index.html

Large diffs are not rendered by default.

131 changes: 67 additions & 64 deletions docs/nitric/api/kv.html
Original file line number Diff line number Diff line change
Expand Up @@ -44,44 +44,38 @@ <h1 class="title">Module <code>nitric.api.kv</code></h1>
# See the License for the specific language governing permissions and
# limitations under the License.
#
from nitric.proto import key_value
from nitric.proto import key_value_service
from nitric.api._base_client import BaseClient
from google.protobuf.struct_pb2 import Struct
from google.protobuf.json_format import MessageToDict
from nitric.proto.kv.v1.kv_pb2 import KeyValueGetResponse
from nitric.utils import new_default_channel, _struct_from_dict
from nitric.proto.nitric.kv.v1 import KeyValueStub


class KeyValueClient(BaseClient):
class KeyValueClient(object):
&#34;&#34;&#34;
Nitric generic document store/db client.

This client insulates application code from stack specific document CRUD operations or SDKs.
&#34;&#34;&#34;

def __init__(self):
&#34;&#34;&#34;Construct a new DocumentClient.&#34;&#34;&#34;
super(self.__class__, self).__init__()
self._stub = key_value_service.KeyValueStub(self._channel)
def __init__(self, collection: str):
&#34;&#34;&#34;
Construct a new DocumentClient.

def put(self, collection: str, key: str, value: dict):
&#34;&#34;&#34;Create a new document with the specified key in the specified collection.&#34;&#34;&#34;
value_struct = Struct()
value_struct.update(value)
request = key_value.KeyValuePutRequest(collection=collection, key=key, value=value_struct)
return self._exec(&#34;Put&#34;, request)
:param collection: name of the key/value collection
&#34;&#34;&#34;
self.collection = collection
self._stub = KeyValueStub(channel=new_default_channel())

def get(self, collection: str, key: str) -&gt; dict:
&#34;&#34;&#34;Retrieve a document from the specified collection by its key.&#34;&#34;&#34;
request = key_value.KeyValueGetRequest(collection=collection, key=key)
reply: KeyValueGetResponse = self._exec(&#34;Get&#34;, request)
document = MessageToDict(reply)[&#34;value&#34;]
return document
async def put(self, key: str, value: dict):
&#34;&#34;&#34;Create a new document with the specified key.&#34;&#34;&#34;
await self._stub.put(collection=self.collection, key=key, value=_struct_from_dict(value))

def delete(self, collection: str, key: str):
async def get(self, key: str) -&gt; dict:
&#34;&#34;&#34;Retrieve a document from the specified key.&#34;&#34;&#34;
response = await self._stub.get(collection=self.collection, key=key)
return response.value.to_dict()

async def delete(self, key: str):
&#34;&#34;&#34;Delete the specified document from the collection.&#34;&#34;&#34;
request = key_value.KeyValueDeleteRequest(collection=collection, key=key)
return self._exec(&#34;Delete&#34;, request)</code></pre>
await self._stub.delete(collection=self.collection, key=key)</code></pre>
</details>
</section>
<section>
Expand All @@ -95,94 +89,94 @@ <h2 class="section-title" id="header-classes">Classes</h2>
<dl>
<dt id="nitric.api.kv.KeyValueClient"><code class="flex name class">
<span>class <span class="ident">KeyValueClient</span></span>
<span>(</span><span>collection: str)</span>
</code></dt>
<dd>
<div class="desc"><p>Nitric generic document store/db client.</p>
<p>This client insulates application code from stack specific document CRUD operations or SDKs.</p>
<p>Construct a new DocumentClient.</p></div>
<p>Construct a new DocumentClient.</p>
<p>:param collection: name of the key/value collection</p></div>
<details class="source">
<summary>
<span>Expand source code</span>
</summary>
<pre><code class="python">class KeyValueClient(BaseClient):
<pre><code class="python">class KeyValueClient(object):
&#34;&#34;&#34;
Nitric generic document store/db client.

This client insulates application code from stack specific document CRUD operations or SDKs.
&#34;&#34;&#34;

def __init__(self):
&#34;&#34;&#34;Construct a new DocumentClient.&#34;&#34;&#34;
super(self.__class__, self).__init__()
self._stub = key_value_service.KeyValueStub(self._channel)
def __init__(self, collection: str):
&#34;&#34;&#34;
Construct a new DocumentClient.

:param collection: name of the key/value collection
&#34;&#34;&#34;
self.collection = collection
self._stub = KeyValueStub(channel=new_default_channel())

def put(self, collection: str, key: str, value: dict):
&#34;&#34;&#34;Create a new document with the specified key in the specified collection.&#34;&#34;&#34;
value_struct = Struct()
value_struct.update(value)
request = key_value.KeyValuePutRequest(collection=collection, key=key, value=value_struct)
return self._exec(&#34;Put&#34;, request)
async def put(self, key: str, value: dict):
&#34;&#34;&#34;Create a new document with the specified key.&#34;&#34;&#34;
await self._stub.put(collection=self.collection, key=key, value=_struct_from_dict(value))

def get(self, collection: str, key: str) -&gt; dict:
&#34;&#34;&#34;Retrieve a document from the specified collection by its key.&#34;&#34;&#34;
request = key_value.KeyValueGetRequest(collection=collection, key=key)
reply: KeyValueGetResponse = self._exec(&#34;Get&#34;, request)
document = MessageToDict(reply)[&#34;value&#34;]
return document
async def get(self, key: str) -&gt; dict:
&#34;&#34;&#34;Retrieve a document from the specified key.&#34;&#34;&#34;
response = await self._stub.get(collection=self.collection, key=key)
return response.value.to_dict()

def delete(self, collection: str, key: str):
async def delete(self, key: str):
&#34;&#34;&#34;Delete the specified document from the collection.&#34;&#34;&#34;
request = key_value.KeyValueDeleteRequest(collection=collection, key=key)
return self._exec(&#34;Delete&#34;, request)</code></pre>
await self._stub.delete(collection=self.collection, key=key)</code></pre>
</details>
<h3>Ancestors</h3>
<ul class="hlist">
<li>nitric.api._base_client.BaseClient</li>
<li>abc.ABC</li>
</ul>
<h3>Methods</h3>
<dl>
<dt id="nitric.api.kv.KeyValueClient.delete"><code class="name flex">
<span>def <span class="ident">delete</span></span>(<span>self, collection: str, key: str)</span>
<span>async def <span class="ident">delete</span></span>(<span>self, key: str)</span>
</code></dt>
<dd>
<div class="desc"><p>Delete the specified document from the collection.</p></div>
<details class="source">
<summary>
<span>Expand source code</span>
</summary>
<pre><code class="python">def delete(self, collection: str, key: str):
<pre><code class="python">async def delete(self, key: str):
&#34;&#34;&#34;Delete the specified document from the collection.&#34;&#34;&#34;
request = key_value.KeyValueDeleteRequest(collection=collection, key=key)
return self._exec(&#34;Delete&#34;, request)</code></pre>
await self._stub.delete(collection=self.collection, key=key)</code></pre>
</details>
</dd>
<dt id="nitric.api.kv.KeyValueClient.get"><code class="name flex">
<span>def <span class="ident">get</span></span>(<span>self, collection: str, key: str) ‑> dict</span>
<span>async def <span class="ident">get</span></span>(<span>self, key: str) ‑> dict</span>
</code></dt>
<dd>
<div class="desc"><p>Retrieve a document from the specified collection by its key.</p></div>
<div class="desc"><p>Retrieve a document from the specified key.</p></div>
<details class="source">
<summary>
<span>Expand source code</span>
</summary>
<pre><code class="python">def get(self, collection: str, key: str) -&gt; dict:
&#34;&#34;&#34;Retrieve a document from the specified collection by its key.&#34;&#34;&#34;
request = key_value.KeyValueGetRequest(collection=collection, key=key)
reply: KeyValueGetResponse = self._exec(&#34;Get&#34;, request)
document = MessageToDict(reply)[&#34;value&#34;]
return document</code></pre>
<pre><code class="python">async def get(self, key: str) -&gt; dict:
&#34;&#34;&#34;Retrieve a document from the specified key.&#34;&#34;&#34;
response = await self._stub.get(collection=self.collection, key=key)
return response.value.to_dict()</code></pre>
</details>
</dd>
<dt id="nitric.api.kv.KeyValueClient.put"><code class="name flex">
<<<<<<< refs/remotes/origin/main
<span>def <span class="ident">put</span></span>(<span>self, collection: str, key: str, value: dict)</span>
</code></dt>
<dd>
<div class="desc"><p>Create a new document with the specified key in the specified collection.</p></div>
=======
<span>async def <span class="ident">put</span></span>(<span>self, key: str, value: dict)</span>
</code></dt>
<dd>
<div class="desc"><p>Create a new document with the specified key.</p></div>
>>>>>>> feat: port faas.start to bi-di streaming with membrane
<details class="source">
<summary>
<span>Expand source code</span>
</summary>
<<<<<<< refs/remotes/origin/main
<pre><code class="python">def put(self, collection: str, key: str, value: dict):
&#34;&#34;&#34;Create a new document with the specified key in the specified collection.&#34;&#34;&#34;
value_struct = Struct()
Expand Down Expand Up @@ -216,6 +210,12 @@ <h3>Instance variables</h3>
<dt id="nitric.api.kv.KeyValueGetResponse.value"><code class="name">var <span class="ident">value</span></code></dt>
<dd>
<div class="desc"><p>Field nitric.kv.v1.KeyValueGetResponse.value</p></div>
=======
<pre><code class="python">async def put(self, key: str, value: dict):
&#34;&#34;&#34;Create a new document with the specified key.&#34;&#34;&#34;
await self._stub.put(collection=self.collection, key=key, value=_struct_from_dict(value))</code></pre>
</details>
>>>>>>> feat: port faas.start to bi-di streaming with membrane
</dd>
</dl>
</dd>
Expand Down Expand Up @@ -243,13 +243,16 @@ <h4><code><a title="nitric.api.kv.KeyValueClient" href="#nitric.api.kv.KeyValueC
<li><code><a title="nitric.api.kv.KeyValueClient.put" href="#nitric.api.kv.KeyValueClient.put">put</a></code></li>
</ul>
</li>
<<<<<<< refs/remotes/origin/main
<li>
<h4><code><a title="nitric.api.kv.KeyValueGetResponse" href="#nitric.api.kv.KeyValueGetResponse">KeyValueGetResponse</a></code></h4>
<ul class="">
<li><code><a title="nitric.api.kv.KeyValueGetResponse.DESCRIPTOR" href="#nitric.api.kv.KeyValueGetResponse.DESCRIPTOR">DESCRIPTOR</a></code></li>
<li><code><a title="nitric.api.kv.KeyValueGetResponse.value" href="#nitric.api.kv.KeyValueGetResponse.value">value</a></code></li>
</ul>
</li>
=======
>>>>>>> feat: port faas.start to bi-di streaming with membrane
</ul>
</li>
</ul>
Expand Down
Loading