Skip to content

Commit

Permalink
Missing file in previous release
Browse files Browse the repository at this point in the history
  • Loading branch information
carsso committed Jun 28, 2020
1 parent 702ab50 commit be68433
Show file tree
Hide file tree
Showing 2 changed files with 80 additions and 14 deletions.
28 changes: 14 additions & 14 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
src/bin
wigocli
generate_cert
src/github.com
uuid
wigo
wigo.*
debs
release
/src/bin
/wigocli
/generate_cert
/src/github.com
/uuid
/wigo
/wigo.*
/debs
/release

# dev
probes/60
ssl
var
wigo.conf.*
huge
/probes/60
/ssl
/var
/wigo.conf.*
/huge

*.log

Expand Down
66 changes: 66 additions & 0 deletions src/wigo/cmaps.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
package wigo

import (
"encoding/json"
"github.com/orcaman/concurrent-map"
)

type concurrentMapWigos struct {
cmap.ConcurrentMap
}


func NewConcurrentMapWigos() *concurrentMapWigos {
return &concurrentMapWigos{
ConcurrentMap: cmap.New(),
}
}

func (m *concurrentMapWigos) UnmarshalJSON(b []byte) (err error) {
// Reverse process of Marshal.

tmp := make(map[string]*Wigo)

// Unmarshal into a single map.
if err := json.Unmarshal(b, &tmp); err != nil {
return nil
}

_m := NewConcurrentMapWigos()
// foreach key,value pair in temporary map insert into our concurrent map.
for key, val := range tmp {
_m.Set(key, val)
}
*m = *_m
return nil
}

type concurrentMapProbes struct {
cmap.ConcurrentMap
}

func NewConcurrentMapProbes() *concurrentMapProbes {
return &concurrentMapProbes{
ConcurrentMap: cmap.New(),
}
}


func (m *concurrentMapProbes) UnmarshalJSON(b []byte) (err error) {
// Reverse process of Marshal.

tmp := make(map[string]*ProbeResult)

// Unmarshal into a single map.
if err := json.Unmarshal(b, &tmp); err != nil {
return nil
}

_m := NewConcurrentMapProbes()
// foreach key,value pair in temporary map insert into our concurrent map.
for key, val := range tmp {
_m.Set(key, val)
}
*m = *_m
return nil
}

0 comments on commit be68433

Please sign in to comment.