Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
72 changes: 36 additions & 36 deletions Cargo.lock

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

33 changes: 33 additions & 0 deletions doc/discovery-service-openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,14 @@ paths:
get:
summary: Get all backends
description: Retrieves a list of all registered Lightning node backends.
parameters:
- name: If-None-Match
in: header
required: false
description: ETag value from a previous response. If it matches the current ETag, returns 304 Not Modified.
schema:
type: string
example: "12345"
responses:
'200':
description: List of backends
Expand All @@ -47,12 +55,37 @@ paths:
schema:
type: string
example: "no-cache"
ETag:
schema:
type: string
description: Current version of the backend list
example: "12345"
content:
application/json:
schema:
type: array
items:
$ref: '#/components/schemas/DiscoveryBackendRest'
'304':
description: Not Modified - backend list hasn't changed since the ETag provided in If-None-Match
headers:
Cache-Control:
schema:
type: string
example: "no-store, no-cache, must-revalidate"
Expires:
schema:
type: string
example: "Thu, 01 Jan 1970 00:00:00 GMT"
Pragma:
schema:
type: string
example: "no-cache"
ETag:
schema:
type: string
description: Current version of the backend list (same as the If-None-Match value)
example: "12345"
/discovery/{addr_variant}/{addr_value}:
get:
summary: Get specific backend
Expand Down
2 changes: 2 additions & 0 deletions migration/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
pub use sea_orm_migration::prelude::*;

pub const DISCOVERY_BACKEND_GET_ALL_ETAG_ID: i32 = 1;

mod m20220101_000001_create_table;
mod m20250724_182058_create_table;

Expand Down
35 changes: 34 additions & 1 deletion migration/src/m20220101_000001_create_table.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
use crate::DISCOVERY_BACKEND_GET_ALL_ETAG_ID;
use sea_orm_migration::{prelude::*, schema::*};

#[derive(DeriveMigrationName)]
Expand Down Expand Up @@ -31,10 +32,35 @@ impl MigrationTrait for DiscoveryBackendMigration {
.primary_key(Index::create().col(DiscoveryBackend::Address))
.to_owned(),
)
.await
.await?;

manager
.create_table(
Table::create()
.table(DiscoveryBackendEtag::Table)
.if_not_exists()
.col(integer(DiscoveryBackendEtag::Id).not_null())
.col(big_integer(DiscoveryBackendEtag::Value).not_null())
.primary_key(Index::create().col(DiscoveryBackendEtag::Id))
.to_owned(),
)
.await?;

let insert_stmt = Query::insert()
.into_table(DiscoveryBackendEtag::Table)
.columns([DiscoveryBackendEtag::Id, DiscoveryBackendEtag::Value])
.values([DISCOVERY_BACKEND_GET_ALL_ETAG_ID.into(), 0.into()])
.map_err(|e| DbErr::Custom(e.to_string()))?
.to_owned();

manager.exec_stmt(insert_stmt).await
}

async fn down(&self, manager: &SchemaManager) -> Result<(), DbErr> {
manager
.drop_table(Table::drop().table(DiscoveryBackendEtag::Table).to_owned())
.await?;

manager
.drop_table(Table::drop().table(DiscoveryBackend::Table).to_owned())
.await
Expand All @@ -54,3 +80,10 @@ enum DiscoveryBackend {
CreatedAt,
UpdatedAt,
}

#[derive(DeriveIden)]
enum DiscoveryBackendEtag {
Table,
Id,
Value,
}
Loading