(key string, m *v1.Message)
| 157 | } |
| 158 | |
| 159 | func (h *handlerDownside) connect(key string, m *v1.Message) error { |
| 160 | // close old chain if exist |
| 161 | old, ok := h.chains.Load(key) |
| 162 | if ok { |
| 163 | err := old.(chain.Chain).Close() |
| 164 | if err != nil { |
| 165 | h.log.Warn("failed to close old chain", log.Any("chain", key)) |
| 166 | } |
| 167 | h.chains.Delete(key) |
| 168 | h.log.Debug("close chain", log.Any("chain name", key)) |
| 169 | } |
| 170 | h.log.Debug("new chain", log.Any("chain name", key)) |
| 171 | |
| 172 | // create new chain |
| 173 | c, err := chain.NewChain(h.cfg, h.ami, m.Metadata) |
| 174 | if err != nil { |
| 175 | h.publishFailedMsg(key, ErrCreateChain, m) |
| 176 | return errors.Trace(err) |
| 177 | } |
| 178 | err = c.Debug() |
| 179 | if err != nil { |
| 180 | h.publishFailedMsg(key, ErrExecData, m) |
| 181 | return errors.Trace(err) |
| 182 | } |
| 183 | h.chains.Store(key, c) |
| 184 | return nil |
| 185 | } |
| 186 | |
| 187 | func (h *handlerDownside) sendExit(key string) { |
| 188 | m := &v1.Message{ |
no test coverage detected