Skip to content

Commit 7cdac83

Browse files
authored
Doc: documentation overhaul, cljdoc compatibility, version bumps (#9)
* Doc: documentation overhaul, cljdoc compatibility, version bumps - Updated dependencies - Adapter libraries now depend on the core SDK. There is no longer a need to explicitly depend on the core SDK. - New articles have been added to the `doc` directory - Several docstrings have been added / updated - New babashka tasks to help running a local cljdoc instance and ingesting the docs locally - The build process now adds libraries interdependencies automatically - libraries are now in a libraries directory instead of the root of the project - Malli schemas have been split into 3 libraries
1 parent 7604154 commit 7cdac83

File tree

80 files changed

+1309
-304
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

80 files changed

+1309
-304
lines changed

.github/workflows/release-sdk.yml

Lines changed: 22 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -59,40 +59,54 @@ jobs:
5959
run: bb test:bb
6060

6161
- name: Build jar artifacts
62-
run: bb jar:all
62+
run: bb install:all
6363

6464
- uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # tag: v4.6.2
6565
with:
6666
name: sdk.jar
67-
path: sdk/target/*.jar
67+
path: libraries/sdk/target/*.jar
68+
if-no-files-found: error
69+
compression-level: 0
70+
71+
- uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # tag: v4.6.2
72+
with:
73+
name: brotli.jar
74+
path: libraries/sdk-brotli/target/*.jar
6875
if-no-files-found: error
6976
compression-level: 0
7077

7178
- uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # tag: v4.6.2
7279
with:
7380
name: adapter-http-kit.jar
74-
path: sdk-adapter-http-kit/target/*.jar
81+
path: libraries/sdk-http-kit/target/*.jar
7582
if-no-files-found: error
7683
compression-level: 0
7784

7885
- uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # tag: v4.6.2
7986
with:
80-
name: adapter-ring.jar
81-
path: sdk-adapter-ring/target/*.jar
87+
name: adapter-http-kit-malli-schemas.jar
88+
path: libraries/sdk-http-kit-malli-schemas/target/*.jar
8289
if-no-files-found: error
8390
compression-level: 0
8491

8592
- uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # tag: v4.6.2
8693
with:
8794
name: malli-schemas.jar
88-
path: sdk-malli-schemas/target/*.jar
95+
path: libraries/sdk-malli-schemas/target/*.jar
8996
if-no-files-found: error
9097
compression-level: 0
9198

9299
- uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # tag: v4.6.2
93100
with:
94-
name: brotli.jar
95-
path: sdk-brotli/target/*.jar
101+
name: adapter-ring.jar
102+
path: libraries/sdk-ring/target/*.jar
103+
if-no-files-found: error
104+
compression-level: 0
105+
106+
- uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # tag: v4.6.2
107+
with:
108+
name: adapter-ring-malli-schemas.jar
109+
path: libraries/sdk-ring-malli-schemas/target/*.jar
96110
if-no-files-found: error
97111
compression-level: 0
98112

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,3 +10,7 @@ test-resources/test.config.edn
1010
/.nfnl.fnl
1111
/.nvim.fnl
1212
/.nvim.lua
13+
14+
.cljdoc-preview
15+
.lazy.fnl
16+
.lazy.lua

CHANGELOG.md

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,30 @@
11
# Release notes for the Clojure SDK
22

3+
## 2025-09-14 - RC2
4+
5+
This release is mostly centered around documentation and cljdoc compatibility.
6+
7+
### Changes
8+
9+
- Several dependencies have been updated
10+
- Libraries interdependencies are now explicit in their `deps.edn`
11+
- Malli schemas are now split into 3 libraries. This comes from the need to be
12+
cljdoc compatible
13+
14+
### Added
15+
16+
- New articles have been added to the `doc` directory
17+
- Several docstrings have been added / updated
18+
- There are new babashka tasks to help running a local cljdoc instance and
19+
ingesting the docs locally
20+
- The build process updates libraries interdependencies versions automatically
21+
- A warning about which Http-kit version to use has been added in the proper
22+
README
23+
24+
### Fixed
25+
26+
- cljdoc ingestion
27+
328
## 2025-06-22
429

530
### Changed
@@ -19,7 +44,7 @@
1944

2045
### Fixed
2146

22-
- A superflous newline character was send when marking the end of a SSE event
47+
- A superfluous newline character was send when marking the end of a SSE event
2348
- The clj-kondo config file for the SDK has been moved in a
2449
`clj-kondo.exports/starfederation.datastar.clojure/sdk` directory. This change
2550
allows for other projects to use

README.md

Lines changed: 10 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -12,30 +12,30 @@ We provide several libraries for working with [Datastar](https://data-star.dev/)
1212

1313
There currently are adapter implementations for:
1414

15-
- [ring](https://github.com/ring-clojure/ring)
15+
- [ring compliant adapters](https://github.com/ring-clojure/ring)
1616
- [http-kit](https://github.com/http-kit/http-kit)
1717

1818
If you want to roll your own adapter implementation, see
1919
[implementing-adapters](/doc/implementing-adapters.md).
2020

21-
## Installation
21+
## Library coordinates
2222

23-
To your `deps.edn` file you can add the following coordinates:
2423

25-
| library | deps coordinate |
26-
| ------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------- |
24+
| library | deps coordinate |
25+
| ------------- | ----------------------------------------------------|
2726
| SDK | [![Clojars Project](https://img.shields.io/clojars/v/dev.data-star.clojure/sdk.svg)](https://clojars.org/dev.data-star.clojure/sdk) |
2827
| http-kit | [![Clojars Project](https://img.shields.io/clojars/v/dev.data-star.clojure/http-kit.svg)](https://clojars.org/dev.data-star.clojure/http-kit) |
2928
| ring | [![Clojars Project](https://img.shields.io/clojars/v/dev.data-star.clojure/ring.svg)](https://clojars.org/dev.data-star.clojure/ring) |
3029
| brotli | [![Clojars Project](https://img.shields.io/clojars/v/dev.data-star.clojure/brotli.svg)](https://clojars.org/dev.data-star.clojure/brotli) |
31-
| malli-schemas | [![Clojars Project](https://img.shields.io/clojars/v/dev.data-star.clojure/malli-schemas.svg)](https://clojars.org/dev.data-star.clojure/malli-schemas) |
30+
| Core SDK malli schemas | [![Clojars Project](https://img.shields.io/clojars/v/dev.data-star.clojure/malli-schemas.svg)](https://clojars.org/dev.data-star.clojure/malli-schemas) |
31+
| Http-kit malli schemas | [![Clojars Project](https://img.shields.io/clojars/v/dev.data-star.clojure/http-kit-malli-schemas.svg)](https://clojars.org/dev.data-star.clojure/http-kit-malli-schemas) |
32+
| Ring malli schemas | [![Clojars Project](https://img.shields.io/clojars/v/dev.data-star.clojure/ring-malli-schemas.svg)](https://clojars.org/dev.data-star.clojure/ring-malli-schemas) |
3233

33-
Notes:
34-
35-
- You need the SDK and either the http-kit or the ring library to get started.
34+
- To get started you'll need either the http-kit library or the ring one.
35+
- Other libraries are optional
3636
- The ring library works with ring compliant adapters (adapter using the
3737
`ring.core.protocols/StreamableResponseBody`)
38-
- Currently the brotli library works only with http-kit
38+
- Currently the Brotli library works only with http-kit
3939

4040
## Usage
4141

@@ -96,9 +96,6 @@ it somewhere and use it later:
9696

9797
```
9898

99-
Check the docstrings in the `starfederation.datastar.clojure.api` namespace for
100-
more details.
101-
10299
### Advanced features
103100

104101
This SDK is essentially a tool to manage SSE connections with helpers to format
@@ -118,40 +115,6 @@ You can find more information in several places:
118115
lists the conventions by which SDK adapters are implemented if the need to
119116
implement your own ever arises.
120117

121-
## Adapter behaviors:
122-
123-
Ring adapters are not made equals. This leads to our SSE generators not having
124-
the exact same behaviors in some cases.
125-
126-
### SSE connection lifetime in ring when trying to store the sse-gen somewhere
127-
128-
#### With ring sync
129-
130-
| Adapter | |
131-
| -------- | ---------------------------------------------------------------------- |
132-
| ring | same as the thread creating the sse response |
133-
| http-kit | alive until the client or the server explicitely closes the connection |
134-
135-
You may keep the connection open in ring sync mode by somehow blocking the thread
136-
handling the request. This is a valid strategy when using java's virtual threads.
137-
138-
#### With ring async
139-
140-
| Adapter | |
141-
| ------------ | ---------------------------------------------------------------------- |
142-
| all adapters | alive until the client or the server explicitely closes the connection |
143-
144-
### Detecting a closed connection
145-
146-
| Adapter | |
147-
| -------- | ----------------------------------------------------------------------------------------------- |
148-
| ring | Sending events on a closed connection will fail at some point and the sse-gen will close itself |
149-
| http-kit | Http-kit detects closed connections by itself and closes the sse-gen |
150-
151-
At this moment, when using the ring adapter and jetty, our SSE generators need
152-
to send 2 small events or 1 big event to detect a closed connection.
153-
There must be some buffering happening independent of our implementation.
154-
155118
## TODO:
156119

157120
- Streamlined release process (cutting releases and publish jar to a maven repo)

bb.edn

Lines changed: 64 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,23 @@
11
{:paths ["src/bb"
2-
"sdk/src/main"
3-
"sdk-adapter-http-kit/src/main/"
4-
"sdk-malli-schemas/src/main"
2+
"libraries/sdk/src/main"
3+
"libraries/sdk-http-kit/src/main/"
4+
"libraries/sdk-http-kit-malli-schemas/src/main"
5+
"libraries/sdk-malli-schemas/src/main"
56
"./src/test/core-sdk"
67
"./src/test/malli-schemas"]
78

8-
:deps {io.github.noahtheduke/lazytest {:mvn/version "1.8.0"}
9-
metosin/malli {:mvn/version "0.17.0"}}
9+
:deps {borkdude/rewrite-edn {:mvn/version "0.4.9"}
10+
io.github.noahtheduke/lazytest {:mvn/version "1.8.0"}
11+
metosin/malli {:mvn/version "0.19.1"}}
1012

1113
:tasks
12-
{:requires ([tasks :as t])
14+
{:requires ([tasks :as t]
15+
[tasks.build :as build]
16+
[tasks.cljdoc :as cljdoc])
1317

18+
;; ---------------------------------------------------------------------------
19+
;; Dev tasks
20+
;; ---------------------------------------------------------------------------
1421
dev
1522
{:doc "Starts a dev repl. Additional deps aliases can be passed as arguments."
1623
:task (t/dev :http-kit :ring-jetty :malli-schemas)}
@@ -22,11 +29,14 @@
2229
dev:empty
2330
{:doc "Dev repl with no adapters."
2431
:task (t/dev :malli-schemas)}
25-
32+
2633
dev:bb
2734
{:doc "Start a babashka nrepl server. An addr like `localhost:1234` can be passed as argument."
2835
:task (t/dev-bb)}
2936

37+
;; ---------------------------------------------------------------------------
38+
;; Test Tasks
39+
;; ---------------------------------------------------------------------------
3040
test:all
3141
{:doc "Run all tests once."
3242
:task (t/lazytest [:http-kit
@@ -67,31 +77,37 @@
6777
{:doc "Run core unit tests with babashka."
6878
:task (t/bb-lazytest [:test.paths/core-sdk
6979
:test.paths/malli-schemas])}
70-
80+
7181
test:sdk-common
7282
{:doc "Run the server used for the SDKs' common tests."
7383
:task (t/start-test-server)}
7484

85+
test:sdk-common-go
86+
{:doc "Run the server used for the SDKs' common tests."
87+
:task (t/run-go-tests)}
7588

89+
;; ---------------------------------------------------------------------------
90+
;; Build tasks
91+
;; ---------------------------------------------------------------------------
7692
jar:sdk
7793
{:doc "Build jar for the common sdk"
78-
:task (t/lib-jar! t/sdk-dir)}
94+
:task (build/lib-jar! build/sdk-dir)}
7995

8096
jar:sdk-adapter-ring
8197
{:doc "Build jar for the adapter-ring"
82-
:task (t/lib-jar! t/sdk-adapter-ring-dir)}
98+
:task (build/lib-jar! build/sdk-adapter-ring-dir)}
8399

84100
jar:sdk-adapter-http-kit
85101
{:doc "Build jar for the adapter-http-kit"
86-
:task (t/lib-jar! t/sdk-adapter-http-kit-dir)}
102+
:task (build/lib-jar! build/sdk-adapter-http-kit-dir)}
87103

88104
jar:sdk-brotli
89105
{:doc "Build jar for the Brotli library"
90-
:task (t/lib-jar! t/sdk-brotli-dir)}
106+
:task (build/lib-jar! build/sdk-brotli-dir)}
91107

92108
jar:sdk-malli-schemas
93109
{:doc "Build jar for the malli-schemas"
94-
:task (t/lib-jar! t/sdk-malli-schemas-dir)}
110+
:task (build/lib-jar! build/sdk-malli-schemas-dir)}
95111

96112
jar:all
97113
{:doc "Build the jar for all the libs"
@@ -102,30 +118,54 @@
102118
jar:sdk-brotli
103119
jar:sdk-malli-schemas]}
104120

121+
install:clean
122+
{:doc "Deletes all datastar libs from the local maven repository."
123+
:task (build/clean-maven-dir!)}
124+
125+
105126
install:all
106-
{:doc "Install all libraries"
127+
{:doc "Install all libraries locally."
107128
:depends [clean]
108-
:task (doseq [dir t/sdk-lib-dirs]
109-
(t/lib-install! dir))}
129+
:task (doseq [dir build/sdk-lib-dirs]
130+
(build/lib-install! dir))}
110131

111132
clean
112-
{:doc "Clean build artifacts"
113-
:task (doseq [dir t/sdk-lib-dirs]
133+
{:doc "Clean build artifacts in each library directory."
134+
:task (doseq [dir build/sdk-lib-dirs]
135+
(println "----------------")
136+
(println "Cleaning: " dir)
137+
(println "----------------")
114138
(clojure {:dir dir} "-T:build clean"))}
115139

116140
set-version
117141
{:doc "Set the version in all libs"
118-
:task (doseq [dir t/sdk-lib-dirs]
119-
(t/lib-set-version! dir (first *command-line-args*)))}
142+
:task (doseq [dir build/sdk-lib-dirs]
143+
(build/lib-set-version! dir (first *command-line-args*)))}
120144

121145
bump-version
122146
{:doc "Bump the version component in all libs. First argument must be one of: major, minor, patch"
123-
:task (doseq [dir sdk-lib-dirs]
147+
:task (doseq [dir build/sdk-lib-dirs]
124148
(let [component (first *command-line-args*)]
125-
(t/lib-bump! dir component)))}
149+
(build/lib-bump! dir component)))}
126150

127151
publish:all
128152
{:doc "Publish the clojure sdk libs to clojars"
129153
:depends [jar:all]
130-
:task (doseq [dir t/sdk-lib-dirs]
131-
(t/lib-publish! dir))}}}
154+
:task (doseq [dir build/sdk-lib-dirs]
155+
(build/lib-publish! dir))}
156+
157+
;; ---------------------------------------------------------------------------
158+
;; Cljdoc tasks
159+
;; ---------------------------------------------------------------------------
160+
cljdoc:clean
161+
{:doc "Clean local cljdoc data."
162+
:task (cljdoc/clean!)}
163+
164+
cljdoc:server
165+
{:doc "Start a local cljdoc server."
166+
:task (cljdoc/start-server!)}
167+
168+
cljdoc:ingest
169+
{:doc "Tell local cljdoc server to ingest a library. Needs a argument (:sdk, :http-kit, :ring, ...)"
170+
:task (cljdoc/ingest! (first *command-line-args*))}}}
171+

0 commit comments

Comments
 (0)