10.0.3 • Published 3 years ago

awv3-node v10.0.3

Weekly downloads
28
License
ISC
Repository
github
Last release
3 years ago

ClassCAD instance manager based on Node.js

This is a Node.js implementation using Socket.IO as the communications protocol.

npm.io

Install

npm install awv3-node

Instance server

The instance manager represents a single endpoint where users connect in order to work with ClassCAD sessions. It may ship ClassCAD binaries and boot them up when starting, but it can also rely on seperate 'farms', servers that host ClassCAD processes.

const path = require('path')
const Server = require('awv3-node/server').default
const Logger = require('awv3-node/extras/logger').default

const server = new Server(
  {
    instances: 1,
    // The following are all defaults ...
    executable: 'ClassCADInstance.exe',
    configurationData: 'CADApplication.ini',
    output: path.resolve('./node_modules/@awv/classcad_cadapplication'),
    protocol: 'http',
    serverOptions: {},
    ip: 'localhost',
    privatePort: 0,
    publicPort: 8181,
    binary: true,
    multipart: true,
    compression: true,
    sendTreePatches: true,
    stdout: false,
    secureApi: false,
    debug: true,
    showConsole: false,
    stateDebounce: 500,
    workerTimeout: 1000 * 15,
    restTimeout: 1000 * 60 * 2,
    collectResultsOnly: true,
    logExpirationDays: 5,
  },
  Logger({ spinOnFirstUser: true }),
).start()

REST API

Log in a new user with the /login endpoint. The user will be treated in the same way as a socket.IO user. This has been abstracted in the awv3 library under the /communication/rest class which features the same API as the socketio or the signalr classes.

GET /login/:id

    response => { op: 'system', status: [either 'permitted' or 'rejected'], id: [session ID] }

Log out with the /logout endpoint

GET /logout/:id

    response => "disconnected"

Execute tasks with the /execute endpoint. Note that due to the limitations of REST, there is no server push available. Results will be sent in a single, complete chunk. Another limitation is that requests may time out, should the server be too busy. Such errors need to be handled by the client.

POST /execute/:id
    headers: {
        'Accept': 'application/json',
        'Content-Type': 'application/json'
    },
    method: "POST",
    body: JSON.stringify(command)

    response => Array of results

Custom load balancing

Override the server.health function to determine the instances health status. The function must return a HTTP status code. Load balancers can probe the /health endpoint to flag single instances as busy, which will remove them from the set of balanced instances until they become active again. The default criteria seeks to flag an instance as not-healthy (status code 503, service unavailable) if 90% of its ClassCAD sessions are busy.

server.health = function() {
  let sessions = Array.from(server.sessions.values())
  let busy = 0
  for (let session of sessions) if (session.tasks.size > 0) busy++

  // If 90% are busy, start flagging the instance as unhealthy
  return busy > sessions.length * 0.9 ? 503 : 200
}
10.0.3

3 years ago

10.0.3-beta.1

3 years ago

10.0.2

3 years ago

10.0.1

4 years ago

10.0.0

4 years ago

9.0.6

4 years ago

9.0.5

4 years ago

9.0.4

4 years ago

9.0.3

5 years ago

9.0.2

6 years ago

9.0.1

6 years ago

9.0.0

6 years ago

8.2.33

6 years ago

8.2.32

6 years ago

8.2.31

6 years ago

8.2.30

6 years ago

8.2.28

6 years ago

8.2.27

6 years ago

8.2.26

6 years ago

8.2.25

6 years ago

8.2.24

6 years ago

8.2.23

6 years ago

8.2.22

6 years ago

8.2.21

6 years ago

8.2.20

6 years ago

8.2.19

6 years ago

8.2.18

6 years ago

8.2.17

6 years ago

8.2.16

6 years ago

8.2.15

6 years ago

8.2.14

6 years ago

8.2.13

6 years ago

8.2.12

6 years ago

8.2.11

6 years ago

8.2.10

6 years ago

8.2.9

6 years ago

8.2.8

6 years ago

8.2.7

6 years ago

7.4.2

6 years ago

8.2.6

6 years ago

8.2.5

6 years ago

8.2.4

6 years ago

8.2.3

6 years ago

8.2.2

6 years ago

8.2.1

6 years ago

8.2.0

6 years ago

8.1.3

6 years ago

8.1.2

6 years ago

8.1.1

6 years ago

8.1.0

6 years ago

8.0.3

6 years ago

8.0.2

6 years ago

8.0.1

6 years ago

8.0.0

6 years ago

7.4.1

6 years ago

7.4.0

6 years ago

7.3.2-beta.2

6 years ago

7.3.2-beta.1

6 years ago

7.3.2

6 years ago

7.3.1

6 years ago

7.3.0

6 years ago

7.2.0

6 years ago

7.1.20

7 years ago

7.1.19

7 years ago

7.1.18

7 years ago

7.1.17

7 years ago

7.1.16-beta1

7 years ago

7.1.16

7 years ago

7.1.15

7 years ago

7.1.14

7 years ago

7.1.13

7 years ago

7.1.12

7 years ago

7.1.11

7 years ago

7.1.10

7 years ago

7.1.9

7 years ago

7.1.8

7 years ago

7.1.7

7 years ago

7.1.6

7 years ago

7.1.5

7 years ago

7.1.4

7 years ago

7.1.3

7 years ago

7.1.2

7 years ago

7.1.1

7 years ago

7.1.0

7 years ago

7.0.5

7 years ago

7.0.4

7 years ago

7.0.2

7 years ago

7.0.1

7 years ago

7.0.0

7 years ago

1.0.64

7 years ago

1.0.63

7 years ago

1.0.62

7 years ago

1.0.61

7 years ago

1.0.60

7 years ago

1.0.59

7 years ago

1.0.58

8 years ago

1.0.57

8 years ago

1.0.56

8 years ago

1.0.55

8 years ago

1.0.54

8 years ago

1.0.53

8 years ago

1.0.52

8 years ago

1.0.51

8 years ago

1.0.50

8 years ago

1.0.49

8 years ago

1.0.48

8 years ago

1.0.46

8 years ago

1.0.45

8 years ago

1.0.44

8 years ago

1.0.43

8 years ago

1.0.42

8 years ago

1.0.41

8 years ago

1.0.40

8 years ago

1.0.39

8 years ago

1.0.37

8 years ago

1.0.36

8 years ago

1.0.35

8 years ago

1.0.34

8 years ago

1.0.33

8 years ago

1.0.32

8 years ago

1.0.31

8 years ago

1.0.30

8 years ago

1.0.29

8 years ago

1.0.27

8 years ago

1.0.26

8 years ago

1.0.25

8 years ago

1.0.24

8 years ago

1.0.23

8 years ago

1.0.22

8 years ago

1.0.21

8 years ago

1.0.20

8 years ago

1.0.19

8 years ago

1.0.18

8 years ago

1.0.17

8 years ago

1.0.16

8 years ago

1.0.15

8 years ago

1.0.13

8 years ago

1.0.12

8 years ago

1.0.11

8 years ago

1.0.10

8 years ago

1.0.9

8 years ago

1.0.8

8 years ago

1.0.7

8 years ago

1.0.6

8 years ago

1.0.5

8 years ago

1.0.4

8 years ago

1.0.3

8 years ago

1.0.2

8 years ago

1.0.1

8 years ago

1.0.0

8 years ago