From 8bdb150788065852a02f496b433e86c2dae2facd Mon Sep 17 00:00:00 2001 From: April Shen Date: Mon, 15 Nov 2021 10:34:26 +0000 Subject: [PATCH] adding sequence diagram --- diagram/README.md | 5 ++++ diagram/sequence-diagram.mmd | 57 ++++++++++++++++++++++++++++++++++++ diagram/sequence-diagram.svg | 1 + 3 files changed, 63 insertions(+) create mode 100644 diagram/README.md create mode 100644 diagram/sequence-diagram.mmd create mode 100644 diagram/sequence-diagram.svg diff --git a/diagram/README.md b/diagram/README.md new file mode 100644 index 00000000..d713264f --- /dev/null +++ b/diagram/README.md @@ -0,0 +1,5 @@ +## Sequence diagram of core accessioning flow + +![sequence diagram](sequence-diagram.svg) + +To regenerate the diagram, copy the [source code](sequence-diagram.mmd) into the [Mermaid live editor](https://mermaid-js.github.io/mermaid-live-editor), or use the [CLI](https://github.com/mermaid-js/mermaid-cli). \ No newline at end of file diff --git a/diagram/sequence-diagram.mmd b/diagram/sequence-diagram.mmd new file mode 100644 index 00000000..3fd4a608 --- /dev/null +++ b/diagram/sequence-diagram.mmd @@ -0,0 +1,57 @@ +sequenceDiagram + +participant Acc Service +participant Acc Generator +participant Block Manager +participant Block Service +participant Postgres +participant DB Service +participant MongoDB + +Acc Service->>Acc Generator: init for instance id +Acc Generator->>Block Service: get incomplete blocks for id & category +Block Service->>Postgres: get incomplete blocks +Postgres->>Block Service: incomplete B(start, end, last) +Block Service->>Acc Generator: incomplete blocks B(s, e, l) +Acc Generator->>Block Manager: add blocks + +Acc Generator->>Block Manager: get available ranges +Block Manager->>Acc Generator: available ranges +Acc Generator->>DB Service: get accessions in ranges +DB Service->>MongoDB: get accessions +MongoDB->>DB Service: accessions +DB Service->>Acc Generator: accessions in mongo but not registered in block +Acc Generator->>Block Manager: recover these +Block Manager->>Block Manager: recompute blocks & ranges + +Acc Service->>Acc Generator: give me 10 accessions +Acc Generator->>Block Manager: enough blocks? +Block Manager->>Acc Generator: yes/no +opt if not + Acc Generator->>Block Service: reserve block for id & category (rs/ss) + Block Service->>Postgres: get last saved block + Postgres->>Block Service: Block{start=0, end=99, last=40} + Block Service->>Block Service: next block + Block Service->>Postgres: save B{s=100, e=199} + note left of Postgres: block reserved for id + Block Service->>Acc Generator: Block{start=100, end=199} + Acc Generator->>Block Manager: add block +end +loop until 10 accessions + Acc Generator->>Block Manager: get accessions from next block + Block Manager->>Acc Generator: next accessions +end +Acc Generator->>Acc Service: here's 10 accessions + +Acc Service->>DB Service: save 10 accessions +DB Service->>MongoDB: save +note left of MongoDB: accessions written +MongoDB->>DB Service: save response +DB Service->>Acc Service: 10 saved, 0 failed +Acc Service->>Acc Generator: post save +Acc Generator->>Block Manager: commit saved accessions +Block Manager->>Acc Generator: update B{s=100, e=199, l=109} +Acc Generator->>Block Service: save B{s=100, e=199, l=109} +Block Service->>Postgres: save B{s=100, e=199, l=109} +note left of Postgres: watermark saved +Acc Generator->>Block Manager: release failed accessions diff --git a/diagram/sequence-diagram.svg b/diagram/sequence-diagram.svg new file mode 100644 index 00000000..066eb848 --- /dev/null +++ b/diagram/sequence-diagram.svg @@ -0,0 +1 @@ +Acc ServiceAcc GeneratorBlock ManagerBlock ServicePostgresDB ServiceMongoDBinit for instance idget incomplete blocks for id & categoryget incomplete blocksincomplete B(start, end, last)incomplete blocks B(s, e, l)add blocksget available rangesavailable rangesget accessions in rangesget accessionsaccessionsaccessions in mongo but not registered in blockrecover theserecompute blocks & rangesgive me 10 accessionsenough blocks?yes/noreserve block for id & category (rs/ss)get last saved blockBlock{start=0, end=99, last=40}next blocksave B{s=100, e=199}block reserved for idBlock{start=100, end=199}add blockopt[if not]get accessions from next blocknext accessionsloop[until 10 accessions]here's 10 accessionssave 10 accessionssaveaccessions writtensave response10 saved, 0 failedpost savecommit saved accessionsupdate B{s=100, e=199, l=109}save B{s=100, e=199, l=109}save B{s=100, e=199, l=109}watermark savedrelease failed accessionsAcc ServiceAcc GeneratorBlock ManagerBlock ServicePostgresDB ServiceMongoDB \ No newline at end of file