Skip to content

Commit

Permalink
Update persistence in dependencies.
Browse files Browse the repository at this point in the history
  • Loading branch information
pwood committed Jun 15, 2024
1 parent 9fe9721 commit 069a00c
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 6 deletions.
2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ github.com/shimmeringbee/persistence v0.0.0-20240615120347-680c4a887f1b h1:TD++F
github.com/shimmeringbee/persistence v0.0.0-20240615120347-680c4a887f1b/go.mod h1:Ob1eKGYM7+9P3LkB9vB9nr15d3trtS4D9KOnGoxOkp8=
github.com/shimmeringbee/persistence v0.0.0-20240615120714-a567d1ac9349 h1:IQ2JhhUVsATqnGav6KOJRqLFDZ80wCYYG3yawTVlylI=
github.com/shimmeringbee/persistence v0.0.0-20240615120714-a567d1ac9349/go.mod h1:Ob1eKGYM7+9P3LkB9vB9nr15d3trtS4D9KOnGoxOkp8=
github.com/shimmeringbee/persistence v0.0.0-20240615141034-6414db99d48e h1:hxB9Zczd27kKbOMoiK56CaHgFKDyIYQLVCD1WV+LlgA=
github.com/shimmeringbee/persistence v0.0.0-20240615141034-6414db99d48e/go.mod h1:Ob1eKGYM7+9P3LkB9vB9nr15d3trtS4D9KOnGoxOkp8=
github.com/shimmeringbee/retry v0.0.0-20221006193055-2ce01bf139c2 h1:HxpPz7w7SxVf1GmcM5oTK1JK64TGpK1UflweYRSOwC4=
github.com/shimmeringbee/retry v0.0.0-20221006193055-2ce01bf139c2/go.mod h1:KYvVq5b7/BSSlWng+AKB5jwNGpc0D7eg8ySWrdPAlms=
github.com/shimmeringbee/zcl v0.0.0-20240614085730-dc48ec71c312 h1:OoFxM9W299ESRnPSR3NoK4+AmWz5PzcJ4gJFZ62nkZ0=
Expand Down
16 changes: 10 additions & 6 deletions provider_load.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,28 +35,32 @@ func (g *gateway) providerLoadDevice(pctx context.Context, n *node, i IEEEAddres
capSection := g.sectionForDevice(i).Section("capability")

for _, cName := range capSection.SectionKeys() {
cctx, cend := g.logger.Segment(ctx, "Loading capability data.", logwrap.Datum("capability", cName))

cSection := capSection.Section(cName)

if capImpl, ok := cSection.String("implementation"); ok {
if capI := factory.Create(capImpl, g.zdaInterface); capI == nil {
g.logger.LogError(ctx, "Could not find capability implementation.", logwrap.Datum("implementation", capImpl))
g.logger.LogError(cctx, "Could not find capability implementation.", logwrap.Datum("implementation", capImpl))
continue
} else {
g.logger.LogInfo(ctx, "Constructed capability implementation.", logwrap.Datum("implementation", capImpl))
g.logger.LogInfo(cctx, "Constructed capability implementation.", logwrap.Datum("implementation", capImpl))
capI.Init(d, cSection.Section("data"))
attached, err := capI.Load(ctx)
attached, err := capI.Load(cctx)

if err != nil {
g.logger.LogError(ctx, "Error while loading from persistence.", logwrap.Err(err), logwrap.Datum("implementation", capImpl))
g.logger.LogError(cctx, "Error while loading from persistence.", logwrap.Err(err), logwrap.Datum("implementation", capImpl))
}

if attached {
g.attachCapabilityToDevice(d, capI)
g.logger.LogInfo(ctx, "Attached capability from persistence.", logwrap.Datum("implementation", capImpl))
g.logger.LogInfo(cctx, "Attached capability from persistence.", logwrap.Datum("implementation", capImpl))
} else {
g.logger.LogWarn(ctx, "Rejected capability attach from persistence.", logwrap.Datum("implementation", capImpl))
g.logger.LogWarn(cctx, "Rejected capability attach from persistence.", logwrap.Datum("implementation", capImpl))
}
}
}

cend()
}
}

0 comments on commit 069a00c

Please sign in to comment.