Skip to content

Commit

Permalink
Merge pull request #255 from NavAbility/develop
Browse files Browse the repository at this point in the history
BlobStore label as param and get[URS]Label
  • Loading branch information
Affie authored Aug 18, 2024
2 parents cfcef12 + 38a336d commit fd03fda
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 11 deletions.
14 changes: 10 additions & 4 deletions src/NavAbilityClient.jl
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,14 @@ end
DFG.getTypeDFGVariables(::DFGClient{T, <:AbstractDFGFactor}) where {T} = T
DFG.getTypeDFGFactors(::DFGClient{<:AbstractDFGVariable, T}) where {T} = T

function DFGClient(client::GQL.Client, context::Context)
function DFGClient(client::GQL.Client, context::Context, storeLabel=:NAVABILITY)
return DFGClient{DFG.Variable, DFG.PackedFactor}(
client,
(id = context.user.id, label = context.user.label),
(id = context.robot.id, label = context.robot.label),
(id = context.session.id, label = context.session.label),
Dict{Symbol, DFG.AbstractBlobStore}(
:NAVABILITY => NavAbilityBlobStore(client, context.user.label),
storeLabel => NavAbilityBlobStore(client, context.user.label),
),
)
end
Expand Down Expand Up @@ -46,6 +46,7 @@ function DFGClient(
userLabel::String,
robotLabel::String,
sessionLabel::String;
storeLabel = :NAVABILITY,
addRobotIfNotExists = false,
addSessionIfNotExists = false,
)
Expand All @@ -64,7 +65,7 @@ function DFGClient(
(id = context.robot.id, label = context.robot.label),
(id = context.session.id, label = context.session.label),
Dict{Symbol, DFG.AbstractBlobStore}(
:NAVABILITY => NavAbilityBlobStore(client, context.user.label),
storeLabel => NavAbilityBlobStore(storeLabel, client, context.user.label),
),
)
end
Expand Down Expand Up @@ -92,4 +93,9 @@ function NavAbilityClient(
authorize ? Dict("Authorization" => "Bearer $auth_token") : Dict{String, String}()
client = GQL.Client(apiUrl; headers, kwargs...)
return client
end
end


DFG.getUserLabel(fg::DFGClient) = fg.user.label
DFG.getRobotLabel(fg::DFGClient) = fg.robot.label
DFG.getSessionLabel(fg::DFGClient) = fg.session.label
10 changes: 5 additions & 5 deletions src/services/BlobStore.jl
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ struct NavAbilityBlobStore <: DFG.AbstractBlobStore{Vector{UInt8}}
userLabel::String
end

NavAbilityBlobStore(client::GQL.Client, userLabel::String) = NavAbilityBlobStore(:NAVABILITY, client, userLabel)
NavAbilityBlobStore(client::GQL.Client, userLabel::String, label = :NAVABILITY) = NavAbilityBlobStore(label, client, userLabel)

function Base.show(io::IO, ::MIME"text/plain", s::NavAbilityBlobStore)
summary(io, s)
Expand All @@ -14,8 +14,8 @@ function Base.show(io::IO, ::MIME"text/plain", s::NavAbilityBlobStore)
println(io, "\n User Name\n ", s.userLabel)
end

function NavAbilityBlobStore(fgclient::DFGClient)
NavAbilityBlobStore(:NAVABILITY, fgclient.client, fgclient.user.label)
function NavAbilityBlobStore(fgclient::DFGClient, label = :NAVABILITY)
NavAbilityBlobStore(label, fgclient.client, fgclient.user.label)
end

struct NavAbilityCachedBlobStore{T <: DFG.AbstractBlobStore} <:
Expand Down Expand Up @@ -241,8 +241,8 @@ struct NavAbilityOnPremBlobStore <: DFG.AbstractBlobStore{Vector{UInt8}}
userLabel::String
end

function NavAbilityOnPremBlobStore(fgclient::DFGClient)
NavAbilityOnPremBlobStore(:NAVABILITY, fgclient.client, fgclient.user.label)
function NavAbilityOnPremBlobStore(fgclient::DFGClient, label=:NAVABILITY)
NavAbilityOnPremBlobStore(label, fgclient.client, fgclient.user.label)
end

function DFG.addBlob!(store::NavAbilityOnPremBlobStore, blobId::UUID, blob::Vector{UInt8})
Expand Down
6 changes: 4 additions & 2 deletions src/services/UserRobotSession.jl
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,9 @@ function setRobotMeta!(fgclient::DFGClient, smallData::Dict{Symbol, DFG.SmallDat
)
end

DFG.getRobotData(fg::DFGClient, key::Symbol) = getRobotMeta(fg)[key]
DFG.setRobotData!(fg::DFGClient, data::Dict{Symbol, DFG.SmallDataTypes}) = setRobotMeta!(fg, data)

##


Expand Down Expand Up @@ -208,9 +211,8 @@ function setSessionMeta!(fgclient::DFGClient, smallData::Dict{Symbol, DFG.SmallD
)
end

DFG.getRobotData(fg::DFGClient, key::Symbol) = getRobotMeta(fg)[key]
DFG.getSessionData(fg::DFGClient, key::Symbol) = getSessionMeta(fg)[key]

DFG.setSessionData!(fg::DFGClient, data::Dict{Symbol, DFG.SmallDataTypes}) = setSessionMeta!(fg, data)

##
function deleteSession!(fgclient::DFGClient)
Expand Down

0 comments on commit fd03fda

Please sign in to comment.