Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ( ErrInvalidMacAddress = errors.New("invalid mac address") ErrGeneratingNodeToken = errors.New("error generating new node token") )
View Source
var ErrGeneratingID = errors.New("generating id failed")
ErrGeneratingID indicates error in generating UUID
Functions ¶
Types ¶
type Node ¶
type Node struct { Addr string `json:"addr"` Name string `json:"name"` Type Type `json:"type"` Status NodeStatus `json:"status"` Latitude string `json:"lat"` Longitude string `json:"long"` Token string `json:"token"` CreatedAt int64 `json:"created_at"` }
Node represent the edge node deployed in the igrid network
type NodeStatus ¶
type NodeStatus int
const ( Revoked NodeStatus = iota + 1 AllowedOffline AllowedOnline )
func (NodeStatus) String ¶
func (ns NodeStatus) String() string
type Repository ¶
type Repository interface { //Save persists the Node information to database Save(ctx context.Context, node Node) error //Get return Node information if a correct MAC Addr is //provided or return error if anything goes wrong Get(ctx context.Context, addr string) (Node, error) //Delete the node from the data store= Delete(ctx context.Context, addr string) error //Update change details of the node Update(ctx context.Context, node Node, addr string) error //List List(ctx context.Context) ([]Node, error) //Auth check if the node is authenticated Auth(ctx context.Context, addr string, token string) (bool, error) //Revoke Revoke(ctx context.Context, addr string, token string) (bool, error) }
func NewPostgreSQL ¶
func NewPostgreSQL(db *sql.DB) Repository
func NewSQLite ¶
func NewSQLite(db *sql.DB) Repository
NewSQLite init sqlite db db, err := sql.Open("sqlite3", "database/regctl.db")
type Service ¶
type Service interface { //Auth check if the node is authenticated Auth(ctx context.Context, addr string, token string) (bool, error) //Add persists the details of a new Node Add(ctx context.Context, node Node) (Node, error) //Delete the existing Node making it invalid Delete(ctx context.Context, addr string) error //Get the details of already persisted node Get(ctx context.Context, addr string) (Node, error) //Update the details of a Node Update(ctx context.Context, addr string, node Node) (Node, error) //List all the valid Nodes List(ctx context.Context) ([]Node, error) //Revoke access Revoke(ctx context.Context, addr, token string) (bool, error) //CheckStatus CheckStatus(ctx context.Context, node Node) (NodeStatus, error) }
Service describes the service.
func NewService ¶
func NewService(repo Repository, logger log.Logger) Service
type UUIDProvider ¶
UUIDProvider specifies an API for generating unique identifiers.
Source Files
¶
Directories
¶
Path | Synopsis |
---|---|
http
THIS FILE IS AUTO GENERATED BY GK-CLI DO NOT EDIT!!
|
THIS FILE IS AUTO GENERATED BY GK-CLI DO NOT EDIT!! |
cmd
|
|
regctl
* Copyright © 2020 PIUS ALFRED <ME.PIUS1102@GMAIL.COM> * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License.
|
* Copyright © 2020 PIUS ALFRED <ME.PIUS1102@GMAIL.COM> * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. |
Click to show internal directories.
Click to hide internal directories.