MCPcopy
hub / github.com/baetyl/baetyl / viewLogs

Method viewLogs

engine/msg_handler.go:124–157  ·  view source on GitHub ↗
(key string, m *v1.Message)

Source from the content-addressed store, hash-verified

122}
123
124func (h *handlerDownside) viewLogs(key string, m *v1.Message) error {
125 // close old chain if exist
126 old, ok := h.chains.Load(key)
127 if ok {
128 err := old.(chain.Chain).Close()
129 if err != nil {
130 h.log.Warn("failed to close old chain", log.Any("chain", key))
131 }
132 h.chains.Delete(key)
133 h.log.Debug("close chain", log.Any("chain name", key))
134 }
135 h.log.Debug("new chain", log.Any("chain name", key))
136
137 opt := &ami.LogsOptions{}
138 err := m.Content.Unmarshal(&opt)
139 if err != nil {
140 h.publishFailedMsg(key, err.Error(), m)
141 return errors.Trace(err)
142 }
143
144 // create new chain
145 c, err := chain.NewChain(h.cfg, h.ami, m.Metadata)
146 if err != nil {
147 h.publishFailedMsg(key, ErrCreateChain, m)
148 return errors.Trace(err)
149 }
150 err = c.ViewLogs(opt)
151 if err != nil {
152 h.publishFailedMsg(key, ErrExecData, m)
153 return errors.Trace(err)
154 }
155 h.chains.Store(key, c)
156 return nil
157}
158
159func (h *handlerDownside) connect(key string, m *v1.Message) error {
160 // close old chain if exist

Callers 1

OnMessageMethod · 0.95

Calls 5

publishFailedMsgMethod · 0.95
ViewLogsMethod · 0.95
NewChainFunction · 0.92
CloseMethod · 0.65
DebugMethod · 0.65

Tested by

no test coverage detected