Skip to content

Bump version #3

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
build.log
.vscode
src/proto/gen/dapr/
5 changes: 0 additions & 5 deletions src/client/src/DaprClient.jl

This file was deleted.

Empty file removed src/client/src/http_client.jl
Empty file.
File renamed without changes.
2 changes: 1 addition & 1 deletion src/client/Project.toml → src/clients/Project.toml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name = "DaprClient"
name = "DaprClients"
uuid = "f4b2537f-2a16-4095-98fc-a229818e8b13"
authors = ["Jun Tian <[email protected]>"]
version = "0.1.0"
104 changes: 104 additions & 0 deletions src/clients/http/Manifest.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
# This file is machine-generated - editing it directly is not advised

[[Artifacts]]
uuid = "56f22d72-fd6d-98f1-02f0-08ddc0907c33"

[[Base64]]
uuid = "2a0f44e3-6c83-55bd-87e4-b1978d98bd5f"

[[Dates]]
deps = ["Printf"]
uuid = "ade2ca70-3891-5945-98fb-dc099432e06a"

[[HTTP]]
deps = ["Base64", "Dates", "IniFile", "Logging", "MbedTLS", "NetworkOptions", "Sockets", "URIs"]
git-tree-sha1 = "14eece7a3308b4d8be910e265c724a6ba51a9798"
uuid = "cd3eb016-35fb-5094-929b-558a96fad6f3"
version = "0.9.16"

[[IniFile]]
deps = ["Test"]
git-tree-sha1 = "098e4d2c533924c921f9f9847274f2ad89e018b8"
uuid = "83e8ac13-25f8-5344-8a64-a9f2b223428f"
version = "0.5.0"

[[InteractiveUtils]]
deps = ["Markdown"]
uuid = "b77e0a4c-d291-57a0-90e8-8db25a27a240"

[[JSON3]]
deps = ["Dates", "Mmap", "Parsers", "StructTypes", "UUIDs"]
git-tree-sha1 = "b3e5984da3c6c95bcf6931760387ff2e64f508f3"
uuid = "0f8b85d8-7281-11e9-16c2-39a750bddbf1"
version = "1.9.1"

[[Libdl]]
uuid = "8f399da3-3557-5675-b5ff-fb832c97cbdb"

[[Logging]]
uuid = "56ddb016-857b-54e1-b83d-db4d58db5568"

[[Markdown]]
deps = ["Base64"]
uuid = "d6f4376e-aef5-505a-96c1-9c027394607a"

[[MbedTLS]]
deps = ["Dates", "MbedTLS_jll", "Random", "Sockets"]
git-tree-sha1 = "1c38e51c3d08ef2278062ebceade0e46cefc96fe"
uuid = "739be429-bea8-5141-9913-cc70e7f3736d"
version = "1.0.3"

[[MbedTLS_jll]]
deps = ["Artifacts", "Libdl"]
uuid = "c8ffd9c3-330d-5841-b78e-0817d7145fa1"

[[Mmap]]
uuid = "a63ad114-7e13-5084-954f-fe012c677804"

[[NetworkOptions]]
uuid = "ca575930-c2e3-43a9-ace4-1e988b2c1908"

[[Parsers]]
deps = ["Dates"]
git-tree-sha1 = "a8709b968a1ea6abc2dc1967cb1db6ac9a00dfb6"
uuid = "69de0a69-1ddd-5017-9359-2bf0b02dc9f0"
version = "2.0.5"

[[Printf]]
deps = ["Unicode"]
uuid = "de0858da-6303-5e67-8744-51eddeeeb8d7"

[[Random]]
deps = ["Serialization"]
uuid = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c"

[[SHA]]
uuid = "ea8e919c-243c-51af-8825-aaa63cd721ce"

[[Serialization]]
uuid = "9e88b42a-f829-5b0c-bbe9-9e923198166b"

[[Sockets]]
uuid = "6462fe0b-24de-5631-8697-dd941f90decc"

[[StructTypes]]
deps = ["Dates", "UUIDs"]
git-tree-sha1 = "8445bf99a36d703a09c601f9a57e2f83000ef2ae"
uuid = "856f2bd8-1eba-4b0a-8007-ebc267875bd4"
version = "1.7.3"

[[Test]]
deps = ["InteractiveUtils", "Logging", "Random", "Serialization"]
uuid = "8dfed614-e22c-5e08-85e1-65c5234f0b40"

[[URIs]]
git-tree-sha1 = "97bbe755a53fe859669cd907f2d96aee8d2c1355"
uuid = "5c2747f8-b7ea-4ff2-ba2e-563bfd36b1d4"
version = "1.3.0"

[[UUIDs]]
deps = ["Random", "SHA"]
uuid = "cf7118a7-6976-5b1a-9a39-7adc72f591a4"

[[Unicode]]
uuid = "4ec0a83e-493e-50e2-b9ac-8f72acf5a8f5"
4 changes: 4 additions & 0 deletions src/clients/http/Project.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
[deps]
HTTP = "cd3eb016-35fb-5094-929b-558a96fad6f3"
JSON3 = "0f8b85d8-7281-11e9-16c2-39a750bddbf1"
URIs = "5c2747f8-b7ea-4ff2-ba2e-563bfd36b1d4"
4 changes: 4 additions & 0 deletions src/clients/src/DaprClients.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
module DaprClients


end # module
4 changes: 4 additions & 0 deletions src/clients/src/grpc/Project.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
name = "DaprGrpcClients"
uuid = "85c08607-b290-480c-96ad-8bed81ae3c14"
authors = ["Jun Tian <[email protected]>"]
version = "0.1.0"
5 changes: 5 additions & 0 deletions src/clients/src/grpc/src/DaprGrpcClients.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
module DaprGrpcClients

greet() = print("Hello World!")

end # module
4 changes: 4 additions & 0 deletions src/clients/src/http/Project.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
name = "DaprHttpClients"
uuid = "301a0fe6-fc23-498b-8f4e-457b3b2177ab"
authors = ["Jun Tian <[email protected]>"]
version = "0.1.0"
231 changes: 231 additions & 0 deletions src/clients/src/http/src/DaprHttpClients.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,231 @@
module DaprHttpClients

export DaprHttpClient

using HTTP
using URIs
using JSON3

function with_path(u::URI, path::String)
URI(;
scheme=u.scheme,
userinfo=u.userinfo,
host=u.host,
port=u.port,
path=path,
query=u.query,
fragment=u.fragment
)
end

const DAPR_VERSION = "v1.0"

struct DaprHttpClient{O}
url::URI
headers::Vector{Pair{String,String}}
options::O
end

function DaprHttpClient(
;
scheme="http",
host="127.0.0.1",
port = 3500,
query = "",
headers = ["content-type" => "application/json"],
options = (readtimeout=60,)
)
url = URI(;scheme=scheme, host=host, port=port, query=query)
DaprHttpClient(url, headers, options)
end

const GLOBAL_DAPR_HTTP_CLIENT = Ref{DaprHttpClient}()

global_dapr_http_client() = GLOBAL_DAPR_HTTP_CLIENT[]
global_dapr_http_client(client) = GLOBAL_DAPR_HTTP_CLIENT[] = client

#####

struct DaprInvocationHttpClient{C<:DaprHttpClient}
app::String
client::C
end

service(app::String) = service(global_dapr_http_client(), app)

service(client, app) = DaprInvocationHttpClient(app, client)

function Base.getproperty(c::DaprInvocationHttpClient, p::Symbol)
app, client = getfield(c, :app), getfield(c, :client)
function invoke(data;verb="GET")
HTTP.request(
verb,
with_path(client.url, "/$(DAPR_VERSION)/invoke/$(app)/method/$p")
client.headers,
data;
client.options...
)
end
end

#####

struct DaprStateHttpClient{C<:DaprHttpClient}
store::String
client::C
end

state(store::String, client=global_dapr_http_client()) = DaprStateHttpClient(store, client)

function Base.setindex!(c::DaprStateHttpClient, v, key::Union{AbstractString,Symbol})
HTTP.request(
"POST",
with_path(c.client.url, "/$(DAPR_VERSION)/state/$(c.store)"),
c.client.headers,
JSON3.write(
[
v isa Tuple ? (key=key, value=v[1], etag=v[2]) : (key=key, value=v)
]
),
;c.client.options...
)
end

function Base.setindex!(c::DaprStateHttpClient, values::AbstractVector, keys::AbstractVector{<:Union{AbstractString,Symbol}})
body = if values isa AbstractVector{<:Tuple}
((key=key, value=v[1], etag=v[2]) for (k,v) in zip(keys, values))
else
((key=key, value=v) for (k,v) in zip(keys, values))
end

HTTP.request(
"POST",
with_path(c.client.url, "/$(DAPR_VERSION)/state/$(c.store)"),
c.client.headers,
JSON3.write(body),
;c.client.options...
)
end

function Base.getindex(c::DaprStateHttpClient, key::Union{AbstractString,Symbol})
HTTP.request(
"GET",
with_path(c.client.url, "/$(DAPR_VERSION)/state/$(c.store)/key/$key"),
c.client.headers,
;c.client.options...
)
end

function Base.getindex(c::DaprStateHttpClient, keys)
HTTP.request(
"POST",
with_path(c.client.url, "/$(DAPR_VERSION)/state/$(c.store)/bulk"),
c.client.headers,
JSON3.write(Dict("keys" => keys))
;c.client.options...
)
end

function Base.delete!(c::DaprStateHttpClient, key)
HTTP.request(
"DELETE",
with_path(c.client.url, "/$(DAPR_VERSION)/state/$(c.store)/$key"),
c.client.headers,
;c.client.options...
)
end

# TODO: define operations, map to StructTypes.DictType()
function (c::DaprStateHttpClient)(operations)
HTTP.request(
"POST",
with_path(c.client.url, "/$(DAPR_VERSION)/state/$(c.store)/transaction"),
c.client.headers,
JSON3.write((operations=operations,))
;c.client.options...
)
end

#####

struct DaprPubsubHttpClient{C<:DaprHttpClient}
name::String
client::C
end

pubsub(name, client=global_dapr_http_client()) = DaprPubsubHttpClient(name, client)

function Base.push!(c::DaprPubsubHttpClient, (topic, data))
HTTP.request(
"POST",
with_path(c.client.url, "/$(DAPR_VERSION)/publish/$(c.name)/$topic"),
c.client.headers,
JSON3.write(data)
;c.client.options...
)
end

#####

# TODO: Actors

#####

struct DaprSecretHttpClient{C<:DaprHttpClient}
store::String
client::C
end

secret(store, client=global_dapr_http_client()) = DaprSecretHttpClient(store, client)

function Base.getindex(c::DaprSecretHttpClient, key::Union{AbstractString,Symbol})
HTTP.request(
"GET",
with_path(c.client.url, "/$(DAPR_VERSION)/secrets/$(c.store)/$key"),
c.client.headers,
;c.client.options...
)
end

function Base.getindex(c::DaprSecretHttpClient)
HTTP.request(
"GET",
with_path(c.client.url, "/$(DAPR_VERSION)/secrets/$(c.store)/bulk"),
c.client.headers,
;c.client.options...
)
end

#####

function healthz(c=global_dapr_http_client())
HTTP.request(
"GET",
with_path(c.client.url, "/$(DAPR_VERSION)/healthz"),
c.client.headers,
;c.client.options...
)
end

#####

function get_metadata(c=global_dapr_http_client())
HTTP.request(
"GET",
with_path(c.client.url, "/$(DAPR_VERSION)/metadata"),
c.client.headers,
;c.client.options...
)
end

function set_metadata!((k,v))
HTTP.request(
"PUT",
with_path(c.client.url, "/$(DAPR_VERSION)/metadata/$k"),
c.client.headers,
v,
;c.client.options...
)
end

end # module
6 changes: 3 additions & 3 deletions src/proto/Manifest.toml
Original file line number Diff line number Diff line change
Expand Up @@ -79,16 +79,16 @@ uuid = "de0858da-6303-5e67-8744-51eddeeeb8d7"

[[ProtoBuf]]
deps = ["Logging", "protoc_jll"]
git-tree-sha1 = "3142e13697a7f6363798d1241daf3e6cead83008"
git-tree-sha1 = "283ac3b9db33300a933a261a16f9aa036d33ac18"
uuid = "3349acd9-ac6a-5e09-bcdb-63829b23a429"
version = "0.11.2"
version = "0.11.4"

[[REPL]]
deps = ["InteractiveUtils", "Markdown", "Sockets", "Unicode"]
uuid = "3fa0cd96-eef1-5676-8a61-b3b8758bbffb"

[[Random]]
deps = ["Serialization"]
deps = ["SHA", "Serialization"]
uuid = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c"

[[SHA]]
Expand Down
Loading