Skip to content

Commit

Permalink
fixing tests
Browse files Browse the repository at this point in the history
  • Loading branch information
zcaudate committed Dec 24, 2024
1 parent d9cfd1c commit d563817
Show file tree
Hide file tree
Showing 17 changed files with 351 additions and 33 deletions.
42 changes: 31 additions & 11 deletions config/publish/foundation.core.edn
Original file line number Diff line number Diff line change
Expand Up @@ -5,40 +5,60 @@
:input "src-doc/documentation/main_index.clj"
:title "foundation"
:subtitle "core libs"}

code-doc
{:input "src-doc/documentation/code_doc.clj"
:title "code.doc"
:subtitle "tools for documentation"}

std-block
{:input "src-doc/documentation/std_block.clj"
:title "std.block"
:subtitle "code representation"}

#_#_
std-lib
{:input "src-doc/documentation/std_lib_foundation.clj"
:title "std.lib.foundation"
:subtitle "basic functionality for foundation"}
{:input "src-doc/documentation/std_lib.clj"
:title "std.lib"
:subtitle "more functionality in std.lib"}

#_#_
std-lib-bin
{:input "src-doc/documentation/std_lib_bin.clj"
:title "std.lib.bin"
:subtitle "basic functionality for buffers"}

#_#_
std-lib-generate
{:input "src-doc/documentation/std_lib_bin.clj"
{:input "src-doc/documentation/std_lib_generate.clj"
:title "std.lib.bin"
:subtitle "basic functionality for buffers"}

std-lib-foundation
{:input "src-doc/documentation/std_lib_foundation.clj"
:title "std.lib.foundation"
:subtitle "basic functionality for foundation"}

#_#_
std-lib-link
{:input "src-doc/documentation/std_lib_foundation.clj"
:title "std.lib.foundation"
:subtitle "basic functionality for foundation"}

#_#_
std-lib-stream
{:input "src-doc/documentation/std_lib_system.clj"
{:input "src-doc/documentation/std_lib_stream.clj"
:title "std.lib.system"
:subtitle "components and subcomponents"}

#_#_
std-lib-system
{:input "src-doc/documentation/std_lib_system.clj"
:title "std.lib.system"
:subtitle "components and subcomponents"}

#_#_
std-lib-zip
{:input "src-doc/documentation/std_lib_system.clj"
{:input "src-doc/documentation/std_lib_zip.clj"
:title "std.lib.system"
:subtitle "components and subcomponents"}
code-doc
{:input "src-doc/documentation/code_doc.clj"
:title "code.doc"
:subtitle "tools for documentation"}}}
:subtitle "components and subcomponents"}}}
Binary file removed hello
Binary file not shown.
5 changes: 2 additions & 3 deletions src-doc/documentation/main_index.clj
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ providing the building blocks for building more declarative and robust systems.
- [lib.oshi](./hara-lib-oshi.html)
- [lib.rabbitmq](./hara-lib-rabbitmq.html)
- [math](./hara-math.html)
- [math.variant](./hara-math-variant.html)
- [math.variant](./hara-m;65;7Math-variant.html)
- [module](./hara-module.html)
- [module.deps](./hara-module-deps.html)
- [module.namespace](./hara-module-namespace.html)
Expand All @@ -61,5 +61,4 @@ providing the building blocks for building more declarative and robust systems.
- [test](./hara-test.html)
- [time](./hara-time.html)
- [tool.monitor](./hara-tool-monitor.html)
- [watch](./hara-watch.html)
"
- [watch](./hara-watch.html)"
32 changes: 32 additions & 0 deletions src-doc/documentation/std_block.clj
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
(ns documentation.std-block)

[[:chapter {:title "Introduction"}]]

"[std.block](https://github.com/zcaudate-xyz/foundation-base/blob/master/src/std/block.clj) provides methods for representation of code."

[[:section {:title "Installation"}]]

"Add to `project.clj` dependencies:
[xyz.zcaudate/base \"{{PROJECT.version}}\"]"

"All functionality is in the `std.block` namespace:"

(comment
(use 'std.block))

[[:chapter {:title "Block" :link "std.block" :module ["std.block.base"]}]]

[[:api {:namespace "std.block.base"}]]

[[:chapter {:title "Type" :link "std.block" :module ["std.block.type"]}]]

[[:api {:namespace "std.block.type"}]]

[[:chapter {:title "Construct" :link "std.block" :module ["std.block.construct"]}]]

[[:api {:namespace "std.block.construct"}]]

[[:chapter {:title "Parse" :link "std.block" :module ["std.block.parse"]}]]

[[:api {:namespace "std.block.parse"}]]
2 changes: 1 addition & 1 deletion src-doc/documentation/std_lib_foundation.clj
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

"Add to `project.clj` dependencies:
[hara/base \"{{PROJECT.version}}\"]"
[xyz.zcaudate/base \"{{PROJECT.version}}\"]"

[[:chapter {:title "Apply" :link "std.lib.apply"}]]

Expand Down
250 changes: 250 additions & 0 deletions src/kmi/redis/sample_type.clj
Original file line number Diff line number Diff line change
@@ -0,0 +1,250 @@
(ns kmi.redis.sample-type
(:require [kmi.redis.compile :as r]
[std.lang :as l])
(:refer-clojure :exclude [>]))

(l/script :lua
{:macro-only true})

(def <BOOK> {:name :book
:type :string})

(def <META> {:type :map
:fields {:__type__ #{"TYPE/BOOK"}
:__status__ #{"BOOK/ACTIVE" "BOOK/INACTIVE"}}
:subscribe ":EVENTS"})

(def <SIDE> {:type :enum :data #{:ask :bid}})

(def <DIFF_DATA> {:type :map
:fields {:frame :integer
:added :set
:removed :set
:modified :map}})

(def <STAGE> {:name :stage
:type #{"I" ;; Initial
"R" ;; Registration
"T" ;; Trade
"X" ;; Closed
}})
(def <FRAME> {:name :frame
:type :integer})
(def <POSITION> {:name :position
:type :integer})
(def <VOLUME> {:name :volume
:type :integer})
(def <AMOUNT> {:name :amount
:type :integer})
(def <ORDER_ID> {:name :order-id
:type :string})

(def <ORDER_DATA> {:type :map
:fields {:id <ORDER_ID>
:side #{:ask :bid}
:position <POSITION>
:frame <FRAME>
:amount <AMOUNT>
:meta :string}})

(def <TX_DATA> {:type :map
:fields {:frame <FRAME>
:sequence :integer
:ask-id <ORDER_ID>
:ask-meta :string
:bid-id <ORDER_ID>
:bid-meta :string
:strike-amount <AMOUNT>
:strike-position <POSITION>}})

(def <FRAME_DATA> {:type :map
:fields {:type #{:place :cancel :modify}
:frame <FRAME>
:order :json}})

(def <ERROR_DATA> {:type :map
:fields {:time :integer
:command :string
:data :string}})

(def <EVENTS> {:type :map
:impl :key
:fields {:_:error {:type :stream
:element <ERROR_DATA>}
:_:frame {:type :stream
:element <FRAME_DATA>}
:_:tx {:type :stream
:element <TX_DATA>}
:_:history {:type :stream
:element {:start <POSITION>
:end <POSITION>
:distribution :json
:volume <VOLUME>}}
:_:volume {:type :stream
:element {:added <VOLUME>
:removed <VOLUME>}}
:_:simulate {:type :stream
:element {:signal <POSITION>}}}})

(def <HISTORY> {:type :map
:impl :key
:fields {:time :integer
:number :integer
:start_frame <FRAME>
:final_frame <FRAME>
:start_position <POSITION>
:final_position <POSITION>
:distribution {:type :map
:impl :hash
:element [<POSITION> <VOLUME>]}
:volume <VOLUME>}})

(def <ORDER_VOLUME> {:type :map
:impl :key
:fields {:time :integer
:number :integer
:start_frame <FRAME>
:final_frame <FRAME>
:added <VOLUME>
:removed <VOLUME>}})

(def <DIFF> {:type :map
:impl :hash
:element [<FRAME> <DIFF_DATA>]})

(def <ORDER> {:type :map
:impl :key
:element [<ORDER_ID> (-> (assoc <ORDER_DATA> :impl :hash)
(update-in
[:fields] assoc
:unfilled <AMOUNT>
:frame-updated <FRAME>
:frame-created <FRAME>
:frame-completed <FRAME>
:priority <FRAME>))]})

(def <ACTIVE_LU> {:type :zset
:element [<ORDER_ID> <POSITION>]})

(def <ACTIVE> {:type :map
:impl :key
:element [<SIDE> <ACTIVE_LU>]})

(def <PRIORITY_LU> {:type :map
:impl :key
:element [<POSITION> {:type :zset
:element [<ORDER_ID> <FRAME>]}]})

(def <PRIORITY> {:type :map
:impl :key
:element [<SIDE> <PRIORITY_LU>]})

(def <UNFILLED_LU> {:type :map
:impl :hash
:element [<POSITION> {:type :integer :name :volume-unfilled}]})

(def <UNFILLED> {:type :map
:impl :key
:element [<SIDE> <UNFILLED_LU>]})

(def <UNFILLED_POSITION> {:type :map
:impl :key
:element [<SIDE> {:type :zset
:element [<POSITION> <POSITION>]}]})

(def <COMPLETED> {:type :zset
:element [<ORDER_ID> <FRAME>]})


(def <SIMULATE> {:type :map
:impl :key
:fields {:position <POSITION>
:frame <FRAME>
:risk {:type :integer}}})

(def <SPEC> {:type :map
:impl :key
:fields {:__meta__ (assoc <META> :impl :hash)
:frame <FRAME>
:stage <STAGE>

:_:order <ORDER>
:events <EVENTS>
:diff <DIFF>

:active <ACTIVE>
:priority <PRIORITY>
:unfilled <UNFILLED>
:position <UNFILLED_POSITION>
:completed <COMPLETED>
:*:history <HISTORY>
:*:volume <ORDER_VOLUME>
:*:simulate <SIMULATE>}})

(def X> (partial r/compile <SPEC>))

(defmacro.lua >
"compiles redis structures compatible with the type schema"
{:added "4.0"}
([& blocks]
(apply r/compile <SPEC> blocks)))

;;
;; Public Meta
;;

(def <PUBLIC-META> {:type :map
:fields {:__type__ #{"TYPE/PUBLIC"}}})

(def <PUBLIC-POSITION> {:type :map
:impl :hash
:element [<BOOK> <POSITION>]})

(def <PUBLIC-POSITION-UPDATED> {:type :map
:impl :hash
:element [<BOOK> :integer]})

(def <PUBLIC-STATUS> {:type :map
:impl :hash
:element [<BOOK> :string]})

(def <PUBLIC-STATUS-FRAME> {:type :map
:impl :hash
:element [<BOOK> :integer]})


(def <PUBLIC-PRIORITY> {:type :map
:impl :hash
:element [<BOOK> :string]})

(def <PUBLIC-PRIORITY-FRAME> {:type :map
:impl :hash
:element [<BOOK> :integer]})


(def <PUBLIC-ACTIVE> {:type :map
:impl :hash
:element [<BOOK> :string]})

(def <PUBLIC-ACTIVE-FRAME> {:type :map
:impl :hash
:element [<BOOK> :integer]})

(def <PUBLIC-SPEC> {:type :map
:impl :key
:fields {:__meta__ (assoc <PUBLIC-META> :impl :hash)
:position <PUBLIC-POSITION>
:position-frame <PUBLIC-STATUS-FRAME>
:position-updated <PUBLIC-POSITION-UPDATED>
:status <PUBLIC-STATUS>
:status-frame <PUBLIC-STATUS-FRAME>
:active <PUBLIC-ACTIVE>
:active-frame <PUBLIC-ACTIVE-FRAME>
:priority <PUBLIC-PRIORITY>
:priority-frame <PUBLIC-PRIORITY-FRAME>}})

(defmacro.lua P>
"compiles redis structures compatible with the public schema"
{:added "4.0"}
([& blocks]
(apply r/compile <PUBLIC-SPEC> blocks)))
2 changes: 1 addition & 1 deletion src/lua/nginx/driver_sqlite.clj
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

(l/script :lua
{:require [[xt.lang.base-lib :as k]]
:import [["lsqlite3" :as ngxsqlite]]
:import [["lsqlite3complete" :as ngxsqlite]]
:export [MODULE]})

(h/template-entries [l/tmpl-entry {:type :fragment
Expand Down
Loading

0 comments on commit d563817

Please sign in to comment.