-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #937 from threefoldtech/development_proxy_indexer_…
…has_ipv6 add new indexer work to check node having ipv6
- Loading branch information
Showing
13 changed files
with
173 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
package indexer | ||
|
||
import ( | ||
"context" | ||
"time" | ||
|
||
"github.com/threefoldtech/tfgrid-sdk-go/grid-proxy/internal/explorer/db" | ||
"github.com/threefoldtech/tfgrid-sdk-go/grid-proxy/pkg/types" | ||
"github.com/threefoldtech/tfgrid-sdk-go/rmb-sdk-go/peer" | ||
) | ||
|
||
const cmd = "zos.network.has_ipv6" | ||
|
||
var _ Work[types.HasIpv6] = (*Ipv6Work)(nil) | ||
|
||
type Ipv6Work struct { | ||
finders map[string]time.Duration | ||
} | ||
|
||
func NewIpv6Work(interval uint) *Ipv6Work { | ||
return &Ipv6Work{ | ||
finders: map[string]time.Duration{ | ||
"up": time.Duration(interval) * time.Minute, | ||
}, | ||
} | ||
} | ||
|
||
func (w *Ipv6Work) Finders() map[string]time.Duration { | ||
return w.finders | ||
} | ||
|
||
func (w *Ipv6Work) Get(ctx context.Context, rmb *peer.RpcClient, id uint32) ([]types.HasIpv6, error) { | ||
var has_ipv6 bool | ||
if err := callNode(ctx, rmb, cmd, nil, id, has_ipv6); err != nil { | ||
return []types.HasIpv6{}, nil | ||
} | ||
|
||
return []types.HasIpv6{ | ||
{ | ||
NodeTwinId: id, | ||
HasIpv6: has_ipv6, | ||
}, | ||
}, nil | ||
} | ||
|
||
func (w *Ipv6Work) Upsert(ctx context.Context, db db.Database, batch []types.HasIpv6) error { | ||
return db.UpsertNodeIpv6Report(ctx, batch) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters