noppoMan / Suv

A libuv based cross platform asyncronous I/O, networking library in Swift. Linux Ready
MIT License
13 stars 0 forks source link

Draft for Message passing between Master and worker #10

Closed noppoMan closed 8 years ago

noppoMan commented 8 years ago

Overview

This specification is for realization message passing between master and worker, and the goal is realization Let it crash!

Here is Example for restarting worker

// master
var worker = Cluster.fork()
worker.send(.Signal(SIGTERM))

worker.on { ev in
     if case .Exit = ev {
         worker = try! worker.fork()
     }
}

// worker
Process.on { ev in
    if case .Signal(let sig) = ev {
        if sig == SIGTERM {
             exit(1)
        }
    }
}

Features

enum InterProcessEvent {
    case Online
    case Exit(UInt64)
    case Error(String)
    case Signal(UInt32)
    case Message(String)
}