mirror of
https://github.com/fnproject/fn.git
synced 2022-10-28 21:29:17 +03:00
@@ -100,22 +100,22 @@ func (m *metricds) GetCalls(ctx context.Context, filter *models.CallFilter) ([]*
|
||||
return m.ds.GetCalls(ctx, filter)
|
||||
}
|
||||
|
||||
func (m *metricds) InsertLog(ctx context.Context, callID string, callLog string) error {
|
||||
func (m *metricds) InsertLog(ctx context.Context, appName, callID, callLog string) error {
|
||||
span, ctx := opentracing.StartSpanFromContext(ctx, "ds_insert_log")
|
||||
defer span.Finish()
|
||||
return m.ds.InsertLog(ctx, callID, callLog)
|
||||
return m.ds.InsertLog(ctx, appName, callID, callLog)
|
||||
}
|
||||
|
||||
func (m *metricds) GetLog(ctx context.Context, callID string) (*models.CallLog, error) {
|
||||
func (m *metricds) GetLog(ctx context.Context, appName, callID string) (*models.CallLog, error) {
|
||||
span, ctx := opentracing.StartSpanFromContext(ctx, "ds_get_log")
|
||||
defer span.Finish()
|
||||
return m.ds.GetLog(ctx, callID)
|
||||
return m.ds.GetLog(ctx, appName, callID)
|
||||
}
|
||||
|
||||
func (m *metricds) DeleteLog(ctx context.Context, callID string) error {
|
||||
func (m *metricds) DeleteLog(ctx context.Context, appName, callID string) error {
|
||||
span, ctx := opentracing.StartSpanFromContext(ctx, "ds_delete_log")
|
||||
defer span.Finish()
|
||||
return m.ds.DeleteLog(ctx, callID)
|
||||
return m.ds.DeleteLog(ctx, appName, callID)
|
||||
}
|
||||
|
||||
// instant & no context ;)
|
||||
|
||||
@@ -138,8 +138,8 @@ func (v *validator) GetCall(ctx context.Context, appName, callID string) (*model
|
||||
return v.Datastore.GetCall(ctx, appName, callID)
|
||||
}
|
||||
|
||||
func (v *validator) DeleteLog(ctx context.Context, callID string) error {
|
||||
return v.Datastore.DeleteLog(ctx, callID)
|
||||
func (v *validator) DeleteLog(ctx context.Context, appName, callID string) error {
|
||||
return v.Datastore.DeleteLog(ctx, appName, callID)
|
||||
}
|
||||
|
||||
// GetDatabase returns the underlying sqlx database implementation
|
||||
|
||||
@@ -61,6 +61,7 @@ var tables = [...]string{`CREATE TABLE IF NOT EXISTS routes (
|
||||
|
||||
`CREATE TABLE IF NOT EXISTS logs (
|
||||
id varchar(256) NOT NULL PRIMARY KEY,
|
||||
app_name varchar(256) NOT NULL,
|
||||
log text NOT NULL
|
||||
);`,
|
||||
}
|
||||
@@ -589,15 +590,15 @@ func (ds *sqlStore) GetCalls(ctx context.Context, filter *models.CallFilter) ([]
|
||||
return res, nil
|
||||
}
|
||||
|
||||
func (ds *sqlStore) InsertLog(ctx context.Context, callID, callLog string) error {
|
||||
query := ds.db.Rebind(`INSERT INTO logs (id, log) VALUES (?, ?);`)
|
||||
_, err := ds.db.ExecContext(ctx, query, callID, callLog)
|
||||
func (ds *sqlStore) InsertLog(ctx context.Context, appName, callID, callLog string) error {
|
||||
query := ds.db.Rebind(`INSERT INTO logs (id, app_name, log) VALUES (?, ?, ?);`)
|
||||
_, err := ds.db.ExecContext(ctx, query, callID, appName, callLog)
|
||||
return err
|
||||
}
|
||||
|
||||
func (ds *sqlStore) GetLog(ctx context.Context, callID string) (*models.CallLog, error) {
|
||||
query := ds.db.Rebind(`SELECT log FROM logs WHERE id=?`)
|
||||
row := ds.db.QueryRowContext(ctx, query, callID)
|
||||
func (ds *sqlStore) GetLog(ctx context.Context, appName, callID string) (*models.CallLog, error) {
|
||||
query := ds.db.Rebind(`SELECT log FROM logs WHERE id=? AND app_name=?`)
|
||||
row := ds.db.QueryRowContext(ctx, query, callID, appName)
|
||||
|
||||
var log string
|
||||
err := row.Scan(&log)
|
||||
@@ -614,9 +615,9 @@ func (ds *sqlStore) GetLog(ctx context.Context, callID string) (*models.CallLog,
|
||||
}, nil
|
||||
}
|
||||
|
||||
func (ds *sqlStore) DeleteLog(ctx context.Context, callID string) error {
|
||||
query := ds.db.Rebind(`DELETE FROM logs WHERE id=?`)
|
||||
_, err := ds.db.ExecContext(ctx, query, callID)
|
||||
func (ds *sqlStore) DeleteLog(ctx context.Context, appName, callID string) error {
|
||||
query := ds.db.Rebind(`DELETE FROM logs WHERE id=? AND app_name=?`)
|
||||
_, err := ds.db.ExecContext(ctx, query, callID, appName)
|
||||
return err
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user