| | |
| | | "basic.com/valib/deliver.git" |
| | | ) |
| | | |
| | | const mode = deliver.PushPull |
| | | |
| | | // Reciever recv from ipc |
| | | type Reciever struct { |
| | | ctx context.Context |
| | |
| | | if r.shm { |
| | | r.runShm(ctx) |
| | | } else { |
| | | r.run(ctx, deliver.NewClient(mode, r.ipcURL)) |
| | | r.run(ctx, deliver.NewServer(deliver.PushPull, r.ipcURL)) |
| | | } |
| | | } |
| | | |
| | |
| | | if r.shm { |
| | | if d, err := i.Recv(); err != nil { |
| | | i.Close() |
| | | r.fnLogger("Reciever RECV ERROR: ", err) |
| | | r.fnLogger("Reciever RECV From:", r.ipcURL, " ERROR: ", err) |
| | | |
| | | c, err := deliver.NewServerWithError(deliver.Shm, r.ipcURL) |
| | | loopR: |
| | | for { |
| | | if err == nil { |
| | | break |
| | | select { |
| | | case <-ctx.Done(): |
| | | return |
| | | default: |
| | | if err == nil { |
| | | break loopR |
| | | } |
| | | time.Sleep(time.Second) |
| | | c, err = deliver.NewServerWithError(deliver.Shm, r.ipcURL) |
| | | r.fnLogger("Recver ANALYSIS CREATE:", r.ipcURL, " FAILED : ", err) |
| | | } |
| | | r.fnLogger("Reciever CREATE FAILED : ", err) |
| | | time.Sleep(time.Second) |
| | | c, err = deliver.NewServerWithError(deliver.Shm, r.ipcURL) |
| | | } |
| | | i = c |
| | | r.fnLogger("Reciever CREATE SHM") |
| | | r.fnLogger("Reciever CREATE SHM:", r.ipcURL) |
| | | } else { |
| | | if d != nil { |
| | | count++ |
| | |
| | | |
| | | func (r *Reciever) runShm(ctx context.Context) { |
| | | c, err := deliver.NewServerWithError(deliver.Shm, r.ipcURL) |
| | | loopRBegin: |
| | | for { |
| | | if err == nil { |
| | | break |
| | | select { |
| | | case <-ctx.Done(): |
| | | return |
| | | default: |
| | | if err == nil { |
| | | break loopRBegin |
| | | } |
| | | time.Sleep(1 * time.Second) |
| | | c, err = deliver.NewServerWithError(deliver.Shm, r.ipcURL) |
| | | r.fnLogger("Recver CLIENT CREATE", r.ipcURL, "FAILED : ", err) |
| | | } |
| | | r.fnLogger("Reciever CLIENT CREATE FAILED : ", err) |
| | | time.Sleep(1 * time.Second) |
| | | c, err = deliver.NewServerWithError(deliver.Shm, r.ipcURL) |
| | | } |
| | | |
| | | r.run(ctx, c) |
| | | } |