Skip to content

Commit

Permalink
core: add check-schema
Browse files Browse the repository at this point in the history
  • Loading branch information
Bogdanp committed Nov 27, 2023
1 parent 4e5e3f0 commit 9e2e4d7
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 0 deletions.
12 changes: 12 additions & 0 deletions core/pool.rkt
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
pool-activate-registry
pool-deactivate-registry
pool-get-schema
pool-check-schema
pool-create-schema
pool-delete-schema
pool-open-iterator
Expand Down Expand Up @@ -334,6 +335,14 @@
(sr:get-schema r name))))
(state-add-req s (req result res-ch nack))]

[`(check-schema ,res-ch ,nack ,id ,name ,schema)
(define result
(call-with-state-schema-registry*
s id
(lambda (r)
(sr:check-schema r name schema))))
(state-add-req s (req result res-ch nack))]

[`(create-schema ,res-ch ,nack ,id ,name ,type ,schema)
(define result
(call-with-state-schema-registry*
Expand Down Expand Up @@ -474,6 +483,9 @@
(define (pool-get-schema id name [p (current-pool)])
(force (sync (pool-send p get-schema id name))))

(define (pool-check-schema id name schema [p (current-pool)])
(force (sync (pool-send p check-schema id name schema))))

(define (pool-create-schema id name type schema [p (current-pool)])
(force (sync (pool-send p create-schema id name type schema))))

Expand Down
5 changes: 5 additions & 0 deletions core/schema-registry.rkt
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,11 @@
[in-workspace id : UVarint] : Schema)
(pool-get-schema id name))

(define-rpc (check-schema [named name : String]
[with-updated-schema schema : String]
[in-workspace id : UVarint])
(pool-check-schema id name schema))

(define-rpc (create-schema [named name : String]
[of-type type : Symbol]
[with-schema schema : String]
Expand Down
11 changes: 11 additions & 0 deletions core/schema-registry/confluent.rkt
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,17 @@
#:version (impl:Schema-version schema)
#:schema (impl:Schema-schema schema)))

(define (check-schema self name schema)
(define client
(confluent-registry-client self))
(define current-schema
(impl:get-subject-version client name 'latest))
(define the-schema
(impl:make-Schema
#:type (impl:Schema-type current-schema)
#:schema schema))
(impl:check-schema client name the-schema))

(define (create-schema self name type schema)
(define client
(confluent-registry-client self))
Expand Down
2 changes: 2 additions & 0 deletions core/schema-registry/generic.rkt
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,15 @@
gen:registry
get-schemas
get-schema
check-schema
create-schema
delete-schema
decode-record)

(define-generics registry
{get-schemas registry}
{get-schema registry name}
{check-schema registry name schema}
{create-schema registry name type schema}
{delete-schema registry name}
{decode-record registry record})

0 comments on commit 9e2e4d7

Please sign in to comment.