1 // Copyright (C) The Arvados Authors. All rights reserved.
3 // SPDX-License-Identifier: AGPL-3.0
12 "git.arvados.org/arvados.git/sdk/go/arvados"
13 "github.com/ghodss/yaml"
14 "github.com/sirupsen/logrus"
17 type eventSink interface {
18 Channel() <-chan *event
22 type eventSource interface {
35 logger logrus.FieldLogger
41 // Detail returns the database row corresponding to the event. It can
42 // be called safely from multiple goroutines. Only one attempt will be
43 // made. If the database row cannot be retrieved, Detail returns nil.
44 func (e *event) Detail() *arvados.Log {
47 if e.logRow != nil || e.err != nil {
50 var logRow arvados.Log
52 e.err = e.db.QueryRow(`SELECT id, uuid, object_uuid, COALESCE(object_owner_uuid,''), COALESCE(event_type,''), event_at, created_at, properties FROM logs WHERE id = $1`, e.LogID).Scan(
56 &logRow.ObjectOwnerUUID,
62 e.logger.WithField("LogID", e.LogID).WithError(e.err).Error("QueryRow failed")
65 e.err = yaml.Unmarshal(propYAML, &logRow.Properties)
67 e.logger.WithField("LogID", e.LogID).WithError(e.err).Error("yaml decode failed")