Documentation
¶
Index ¶
- Constants
- Variables
- func AcceptFileTransfer(ctx context.Context, incomingFileTransfer IncomingFileTransfer) (string, <-chan utils.IOProgress, error)
- func AcceptPeerFileTransfer(ctx context.Context, w http.ResponseWriter, r *http.Request) error
- func Bootstrap(ctx context.Context, node host.Host, idht *dht.IpfsDHT) error
- func ChangeDeviceStatus(status bool) error
- func CheckOnboarding()
- func CleanupOldPeers()
- func CleanupPeer(id peer.ID) error
- func ClearIncomingChatRequests() error
- func ClearIncomingFileRequests() error
- func CreateChatStream(ctx context.Context, id peer.ID) (network.Stream, error)
- func DMSp2pSet(node host.Host, dht *dht.IpfsDHT)
- func DefaultDepReqPeer(ctx context.Context, id string) (string, error)
- func DeploymentUpdate(msgType string, msg string, close bool) error
- func DeploymentUpdateListener(stream network.Stream)
- func DeviceStatus() (bool, error)
- func DumpDHT(ctx context.Context) ([]models.PeerData, error)
- func DumpKademliaDHT(ctx context.Context) ([]models.PeerData, error)
- func FetchAvailableResources(node host.Host) []models.FreeResources
- func FetchMachines(node host.Host) models.Machines
- func FileReadStreamWrite(file *os.File, stream network.Stream, w io.Writer)
- func GenerateKey(seed int64) (crypto.PrivKey, crypto.PubKey, error)
- func GetConnections() ([]models.Connection, error)
- func GetDHTUpdates(ctx context.Context)
- func GetPrivateKey() (crypto.PrivKey, error)
- func GetPublicKey() (crypto.PubKey, error)
- func IncomingFileTransferRequests() (string, error)
- func InitiateTransferFile(ctx context.Context, w http.ResponseWriter, r *http.Request, id peer.ID, ...) error
- func IsDepReqStreamOpen() bool
- func IsDepRespStreamOpen() bool
- func JoinChat(w http.ResponseWriter, r *http.Request, id int) error
- func ListCheckpoints() ([]checkpoint, error)
- func ListDHTPeers(ctx context.Context) ([]peer.ID, error)
- func ListKadDHTPeers(ctx, reqCtx context.Context) ([]string, error)
- func ListPeers() ([]peer.AddrInfo, error)
- func ManualDHTUpdate(ctx context.Context)
- func NewHost(ctx context.Context, priv crypto.PrivKey, server bool) (host.Host, *dht.IpfsDHT, error)
- func OldPing(ctx context.Context, h host.Host, target peer.ID) models.PingResultdeprecated
- func OldPingPeer(ctx context.Context, target peer.ID) (bool, *models.PingResult)
- func PeersWithAvailability(peers []models.PeerData) []models.PeerData
- func PeersWithCardanoAllowed(peers []models.PeerData) []models.PeerData
- func PeersWithGPU(peers []models.PeerData) []models.PeerData
- func PeersWithMatchingSpec(peers []models.PeerData, depReq models.DeploymentRequest) []models.PeerData
- func Ping(ctx context.Context, targetPeer peer.ID) (<-chan ping.Result, func())
- func PingHandler(s network.Stream)
- func PingPeer(ctx context.Context, target peer.ID) (bool, ping.Result)
- func RemoveConnection(conn models.Connection) error
- func RunNode(priv crypto.PrivKey, server bool, available bool) error
- func SaveNodeInfo(priv crypto.PrivKey, pub crypto.PubKey, serverMode bool, available bool) error
- func SendDeploymentRequest(ctx context.Context, depReq models.DeploymentRequest) (network.Stream, error)
- func SendFileToPeer(ctx context.Context, peerID peer.ID, filePath string, ...) (<-chan utils.IOProgress, error)
- func ShutdownNode() error
- func SockReadStreamWrite(conn *internal.WebSocketConnection, stream network.Stream, w *bufio.Writer)
- func StartChat(w http.ResponseWriter, r *http.Request, s network.Stream, id string)
- func StreamReadFileWrite(ctxDone context.CancelFunc, incomingFileTransfer IncomingFileTransfer, ...)
- func StreamReadSockWrite(conn *internal.WebSocketConnection, stream network.Stream, r *bufio.Reader)
- func UpdateConnections(conns []network.Conn) error
- func UpdateKadDHT()
- type DMSp2p
- type FileMetadata
- type FileTransferResult
- type FileTransferType
- type IncomingFileTransfer
- type OpenStream
- type SelfPeer
Constants ¶
const ( // Stream Protocols // Stream Protocol for Deployment Requests DepReqProtocolID = "/nunet/dms/depreq/0.0.3" // Stream Protocol for Chat ChatProtocolID = "/nunet/dms/chat/0.0.1" // Stream Protocol for File Transfer FileTransferProtocolID = "/nunet/dms/file/0.0.1" // Stream Protocol for Ping PingProtocolID = "/nunet/dms/ping/0.0.2" // Rendezvous Points // Team Rendezvous TeamRendezvous = "nunet-team" // Edge Rendezvous EdgeRendezvous = "nunet-edge" // Test Rendezvous TestRendezvous = "nunet-test" // Staging Rendezvous StagingRendezvous = "nunet-staging" // Prod Rendezvous ProdRendezvous = "nunet" )
const ( MsgDepResp = "DepResp" MsgDepReq = "DepReq" MsgJobStatus = "JobStatus" MsgLogStderr = "LogStderr" MsgLogStdout = "LogStdout" )
Constants containing all message types happening between peers.
const ( ContainerJobPending = "pending" ContainerJobRunning = "running" ContainerJobFinishedWithErrors = "finished with errors" ContainerJobFinishedWithoutErrors = "finished without errors" ContainerJobFailed = "failed" )
constants for job status messaging
const ( JobSubmitted = "job-submitted" JobFailed = "job-failed" JobCompleted = "job-completed" )
constants for job status actions
Variables ¶
var ( DepReqQueue = make(chan models.DeploymentRequest) DepResQueue = make(chan models.DeploymentResponse) JobLogStderrQueue = make(chan string) JobLogStdoutQueue = make(chan string) JobFailedQueue = make(chan string) JobCompletedQueue = make(chan string) FileTransferQueue = make(chan IncomingFileTransfer) )
var FS afero.Fs = afero.NewOsFs()
var InboundDepReqStream network.Stream
var (
// bootstrap peers provided by NuNet
NuNetBootstrapPeers []multiaddr.Multiaddr
)
var OutboundDepReqStream network.Stream
Functions ¶
func AcceptFileTransfer ¶ added in v0.4.159
func AcceptFileTransfer(ctx context.Context, incomingFileTransfer IncomingFileTransfer) (string, <-chan utils.IOProgress, error)
AcceptFileTransfer accepts the file transfer and returns a file path of location where file is written as well as the progress channel with info on how much data is transferred.
func AcceptPeerFileTransfer ¶ added in v0.4.159
Temporary wrapper around AcceptFileTransfer, adds WebSocket layer
func ChangeDeviceStatus ¶ added in v0.4.159
func CheckOnboarding ¶
func CheckOnboarding()
func ClearIncomingChatRequests ¶ added in v0.4.159
func ClearIncomingChatRequests() error
func ClearIncomingFileRequests ¶ added in v0.4.159
func ClearIncomingFileRequests() error
func CreateChatStream ¶ added in v0.4.159
func DMSp2pSet ¶ added in v0.4.159
XXX bad implementation - don't use. Temporary measure for routes_test calling HandleRequestService
func DefaultDepReqPeer ¶
SUGGESTION: Define two functions SetDepReqPeer and GetDepReqPeer Current function have both SET and GET logic which make things confusing
func DeploymentUpdate ¶
DeploymentUpdate is an auxilary function to send updates from one machine to another Args:
msgType: one of MsgDepResp, MsgDepReq, MsgDepReqUpdate, MsgJobStatus, MsgLogStderr, MsgLogStdout msg: message to send inbound: true if the depReq was inbound (DMS is CP) or false if depReq was outbound (DMS is SP) close: true if the depReq stream needs to be closed after sending the message
func DeploymentUpdateListener ¶
DeploymentUpdateListener listens for deployment response and service running status.
func DeviceStatus ¶ added in v0.4.159
func DumpKademliaDHT ¶
DEBUG ONLY
func FetchAvailableResources ¶
func FetchAvailableResources(node host.Host) []models.FreeResources
FetchAvailableResources returns AvailableResources on DHT.
func FetchMachines ¶
FetchMachines returns Machines on DHT.
func FileReadStreamWrite ¶ added in v0.4.159
func GetConnections ¶
func GetConnections() ([]models.Connection, error)
func GetDHTUpdates ¶
Fetches peer info of peers from Kad-DHT and updates Peerstore.
func GetPrivateKey ¶
func GetPublicKey ¶
func IncomingFileTransferRequests ¶ added in v0.4.159
func InitiateTransferFile ¶ added in v0.4.159
func IsDepReqStreamOpen ¶
func IsDepReqStreamOpen() bool
func IsDepRespStreamOpen ¶
func IsDepRespStreamOpen() bool
func ListCheckpoints ¶ added in v0.4.159
func ListCheckpoints() ([]checkpoint, error)
func OldPing
deprecated
added in
v0.4.159
Deprecated: Use Ping instead which returns a channel of ping results and a context cancel function OldPing manualy pings the given peer and returns the result which contains success/fail status, RTT and and error message if any.
func OldPingPeer ¶ added in v0.4.159
DEBUG ONLY
func PeersWithAvailability ¶ added in v0.4.159
Filter function which returns a slice of the PeerData struct containing peers that are available.
func PeersWithCardanoAllowed ¶
PeersWithCardanoAllowed is a filter function which returns a slice of PeerData based on allow_cardano metadata on peer.
func PeersWithGPU ¶
PeersWithGPU is a filter function which returns a slice of PeerData based on has_gpu metadata on peer.
func PeersWithMatchingSpec ¶
func PeersWithMatchingSpec(peers []models.PeerData, depReq models.DeploymentRequest) []models.PeerData
PeersWithMatchingSpec takes in a depReq which has minimum spec specified to run a job. Then it matches it against the peers available.
func PingHandler ¶
PingHandler handles an incoming ping. This implementation handles two protocols: 1. The old protocol for backward compatibility (/nunet/dms/ping/0.0.1) 2. The new protocol (/ipfs/ping/1.0.0) The old protocol will be deprecated soon.
func RemoveConnection ¶
func RemoveConnection(conn models.Connection) error
func SaveNodeInfo ¶
func SendDeploymentRequest ¶
func SendFileToPeer ¶ added in v0.4.159
func SendFileToPeer(ctx context.Context, peerID peer.ID, filePath string, transferType FileTransferType) (<-chan utils.IOProgress, error)
SendFileToPeer takes a libp2p peer id and a file path and sends the file to the peer.
func ShutdownNode ¶ added in v0.4.118
func ShutdownNode() error
func SockReadStreamWrite ¶
func StreamReadFileWrite ¶ added in v0.4.159
func StreamReadFileWrite(ctxDone context.CancelFunc, incomingFileTransfer IncomingFileTransfer, file *os.File, r io.Reader)
func StreamReadSockWrite ¶
func UpdateConnections ¶
UpdateConnections updates the database with the current connections.
func UpdateKadDHT ¶
func UpdateKadDHT()
UpdateKadDHT updates the Kad-DHT with the current node's peer info
Types ¶
type DMSp2p ¶
type FileMetadata ¶ added in v0.4.159
type FileTransferResult ¶ added in v0.4.159
type FileTransferResult struct { FilePath string TransferChan <-chan utils.IOProgress Error error }
type FileTransferType ¶ added in v0.4.159
type FileTransferType uint8
const ( FTDEPREQ FileTransferType = 0 // depreq related file transfer FTMISC FileTransferType = 1 // misc file transfer )
type IncomingFileTransfer ¶ added in v0.4.159
type IncomingFileTransfer struct { ID int File FileMetadata Time time.Time Sender peer.ID SenderPublicKey crypto.PubKey InboundFileStream network.Stream }
var CurrentFileTransfer IncomingFileTransfer
type OpenStream ¶ added in v0.4.159
type OpenStream struct { ID int `json:"id"` StreamID string `json:"stream_id"` FromPeer string `json:"from_peer"` TimeOpened string `json:"time_opened"` }
func IncomingChatRequests ¶ added in v0.4.159
func IncomingChatRequests() ([]OpenStream, error)