Skip to content

Commit

Permalink
feat: recon-over-http (#168)
Browse files Browse the repository at this point in the history
* feat: recon-over-http

* feat: struct HashCount

* fix: review comments and minor refactor

* fix: metrics for api

* fix: incorporate review comments

---------

Co-authored-by: Aaron D Goldman <[email protected]>
  • Loading branch information
smrz2001 and AaronGoldman authored Jan 11, 2024
1 parent 3a418bb commit 28d8dd3
Show file tree
Hide file tree
Showing 36 changed files with 944 additions and 185 deletions.
87 changes: 5 additions & 82 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ lru = "0.10"
mime = "0.3"
mime_classifier = "0.0.1"
mime_guess = "2.0.4"
minicbor = { version = "0.19.1", features = ["alloc", "std"] }
minicbor = { version = "0.19.1", features = ["std", "derive", "half"] }
mockall = "0.11.4"
multiaddr = "0.18"
multibase = "0.9"
Expand Down Expand Up @@ -134,6 +134,7 @@ ruzstd = "0.3"
serde = { version = "1.0", features = ["derive"] }
serde-error = "0.1.2"
serde_bytes = "0.11"
serde_cbor = "0.11.2"
serde_ipld_dagcbor = "0.3"
serde_json = "1.0.87"
serde_qs = "0.10.1"
Expand Down
1 change: 1 addition & 0 deletions api-server/.openapi-generator/FILES
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ Cargo.toml
README.md
api/openapi.yaml
docs/Event.md
docs/Ring.md
docs/Version.md
docs/default_api.md
examples/ca.pem
Expand Down
2 changes: 2 additions & 0 deletions api-server/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -100,13 +100,15 @@ Method | HTTP request | Description
------------- | ------------- | -------------
[****](docs/default_api.md#) | **POST** /events | Creates a new event
[****](docs/default_api.md#) | **GET** /liveness | Test the liveness of the Ceramic node
[****](docs/default_api.md#) | **POST** /recon | Sends a Recon message
[****](docs/default_api.md#) | **GET** /subscribe/{sort_key}/{sort_value} | Get events for a stream
[****](docs/default_api.md#) | **POST** /version | Get the version of the Ceramic node


## Documentation For Models

- [Event](docs/Event.md)
- [Ring](docs/Ring.md)
- [Version](docs/Version.md)


Expand Down
37 changes: 36 additions & 1 deletion api-server/api/openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,28 @@ paths:
"204":
description: success
summary: Creates a new event
/recon:
post:
parameters:
- description: Recon ring
explode: true
in: query
name: ring
required: true
schema:
$ref: '#/components/schemas/Ring'
style: form
requestBody:
$ref: '#/components/requestBodies/Message'
responses:
"200":
content:
application/cbor-seq:
schema:
format: binary
type: string
description: success
summary: Sends a Recon message
components:
requestBodies:
Event:
Expand All @@ -105,6 +127,14 @@ components:
$ref: '#/components/schemas/Event'
description: Event to add to the node
required: true
Message:
content:
application/cbor-seq:
schema:
format: byte
type: string
description: Recon message to send
required: true
schemas:
Version:
description: "Version of the Ceramic node in semver format, e.g. 2.1.0"
Expand All @@ -120,10 +150,15 @@ components:
eventId: eventId
properties:
eventId:
description: Multibase encodeding of event id bytes.
description: Multibase encoding of event id bytes.
type: string
required:
- eventId
title: A Ceramic Event
type: object
Ring:
enum:
- interest
- model
type: string

2 changes: 1 addition & 1 deletion api-server/docs/Event.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
## Properties
Name | Type | Description | Notes
------------ | ------------- | ------------- | -------------
**event_id** | **String** | Multibase encodeding of event id bytes. |
**event_id** | **String** | Multibase encoding of event id bytes. |

[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)

Expand Down
10 changes: 10 additions & 0 deletions api-server/docs/Message.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# Message

## Properties
Name | Type | Description | Notes
------------ | ------------- | ------------- | -------------
**msg** | [***swagger::ByteArray**](file.md) | CBOR payload of Recon message |

[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)


9 changes: 9 additions & 0 deletions api-server/docs/Ring.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# Ring

## Properties
Name | Type | Description | Notes
------------ | ------------- | ------------- | -------------

[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)


27 changes: 27 additions & 0 deletions api-server/docs/default_api.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ Method | HTTP request | Description
------------- | ------------- | -------------
****](default_api.md#) | **POST** /events | Creates a new event
****](default_api.md#) | **GET** /liveness | Test the liveness of the Ceramic node
****](default_api.md#) | **POST** /recon | Sends a Recon message
****](default_api.md#) | **GET** /subscribe/{sort_key}/{sort_value} | Get events for a stream
****](default_api.md#) | **POST** /version | Get the version of the Ceramic node

Expand Down Expand Up @@ -57,6 +58,32 @@ No authorization required

[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md)

# ****
> swagger::ByteArray (ring, body)
Sends a Recon message

### Required Parameters

Name | Type | Description | Notes
------------- | ------------- | ------------- | -------------
**ring** | [****](.md)| Recon ring |
**body** | **swagger::ByteArray**| Recon message to send |

### Return type

[**swagger::ByteArray**](file.md)

### Authorization

No authorization required

### HTTP request headers

- **Content-Type**: application/cbor-seq
- **Accept**: application/cbor-seq

[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md)

# ****
> Vec<models::Event> (sort_key, sort_value, optional)
Get events for a stream
Expand Down
11 changes: 10 additions & 1 deletion api-server/examples/client/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
#[allow(unused_imports)]
use ceramic_api_server::{
models, Api, ApiNoContext, Client, ContextWrapperExt, EventsPostResponse, LivenessGetResponse,
SubscribeSortKeySortValueGetResponse, VersionPostResponse,
ReconPostResponse, SubscribeSortKeySortValueGetResponse, VersionPostResponse,
};
use clap::{App, Arg};
#[allow(unused_imports)]
Expand Down Expand Up @@ -103,6 +103,15 @@ fn main() {
(client.context() as &dyn Has<XSpanIdString>).get().clone()
);
}
/* Disabled because there's no example.
Some("ReconPost") => {
let result = rt.block_on(client.recon_post(
???,
swagger::ByteArray(Vec::from("BYTE_ARRAY_DATA_HERE"))
));
info!("{:?} (X-Span-ID: {:?})", result, (client.context() as &dyn Has<XSpanIdString>).get().clone());
},
*/
Some("SubscribeSortKeySortValueGet") => {
let result = rt.block_on(client.subscribe_sort_key_sort_value_get(
"sort_key_example".to_string(),
Expand Down
Loading

0 comments on commit 28d8dd3

Please sign in to comment.