internal

package
v0.5.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 30, 2024 License: Apache-2.0 Imports: 6 Imported by: 0

README

internal

Table of Contents

  1. Description
  2. Structure and Organisation
  3. Class Diagram
  4. Functionality
  5. Data Types
  6. Testing
  7. Proposed Functionality/Requirements
  8. References

Specification

Description

This package contains all code that is very specific to the whole of the dms, which will not be imported by any other packages and used only on the running instance of dms (like config and background task).

Structure and Organisation

Here is quick overview of the contents of this pacakge:

  • README: Current file which is aimed towards developers who wish to use and modify the package functionality.

  • init: This file handles controlled shutdown and initializes OpenTelemetry-based Zap logger.

  • websocket: This file contains communication protocols for a websocket server including message handling and command execution.

subpackages

  • config: This sub-package contains the configuration related data for the whole dms.

  • background_tasks: This sub-package contains functionality that runs in the background.

Class Diagram
Source

internal class diagram

Rendered from source file
!$rootUrlGitlab = "https://gitlab.com/nunet/device-management-service/-/raw/main"
!$packageRelativePath = "/internal"
!$packageUrlGitlab = $rootUrlGitlab + $packageRelativePath
 
!include $packageUrlGitlab/specs/class_diagram.puml
Functionality

TBD

Data Types
  • internal.WebSocketConnection
// WebSocketConnection is pointer to gorilla/websocket.Conn
type WebSocketConnection struct {
	*websocket.Conn
}
  • internal.Command
// Command represents a command to be executed
type Command struct {
	Command string
	NodeID  string // ID of the node where command will be executed
	Result  string
	Conn    *WebSocketConnection
}

Note: The data types are expected to change during refactoring of DMS

Testing

TBD

Proposed Functionality / Requirements
List of issues

All issues that are related to the implementation of internal package can be found below. These include any proposals for modifications to the package or new functionality needed to cover the requirements of other packages.

References

Documentation

Overview

Package internal is a work in progress. It is planned to accommodate modules such as db and types.

Index

Constants

This section is empty.

Variables

View Source
var ShutdownChan chan os.Signal
View Source
var UpgradeConnection = websocket.Upgrader{
	ReadBufferSize:  1024,
	WriteBufferSize: 1024,
	CheckOrigin:     func(_ *http.Request) bool { return true },
}

UpgradeConnection is generic protocol upgrader for entire DMS.

Functions

func ListenForWs

func ListenForWs(conn *WebSocketConnection)

ListenForWs listens to the connected client for any message. It is assumed that every message that is coming is a command to be executed.

func SendCommandForExecution

func SendCommandForExecution()

SendCommandForExecution work is to send command for execution and fetch the result This function listens for new commands from commandChan

Types

type Command

type Command struct {
	Command string
	NodeID  string // ID of the node where command will be executed
	Result  string
	Conn    *WebSocketConnection
}

Command represents a command to be executed

type WebSocketConnection

type WebSocketConnection struct {
	*websocket.Conn
}

WebSocketConnection is pointer to gorilla/websocket.Conn

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL
JackTT - Gopher 🇻🇳