mirror of
https://github.com/fnproject/fn.git
synced 2022-10-28 21:29:17 +03:00
something still feels off with this, but i tinkered with it for a day-ish and didn't come up with anything a whole lot better. doing a lot of the maneuvering in the caller seemed better but it was just bloating up GetCall so went back to having it basically like it was, but returning the limited underlying buffer to read from so we can ship to the db. some small changes to the LogStore interface, swapped it to take an io.Reader instead of a string for more flexibility in the future while essentially maintaining the same level of performance that we have now. i'm guessing in the not so distant future we'll ship these to some s3 like service and it would be better to stream them in than carry around a giant string anyway. also, carrying around up to 1MB buffers in memory isn't great, we may want to switch to file backed logs for calls, too. using io.Reader for logs should make #279 more reasonable if/once we move to some s3-like thing, we can stream from the log storage service direct to clients. this fixes the span being out of whack and allows the 'right' context to be used to upload logs (next to inserting the call). deletes the dbWriter we had, and we just do this in call.End now (which makes sense to me at least). removes the dupe code for making an stderr for hot / cold and simplifies the way to get a func logger (no more 7 param methods yay). closes #298
22 lines
650 B
Go
22 lines
650 B
Go
package models
|
|
|
|
import (
|
|
"context"
|
|
"io"
|
|
)
|
|
|
|
type LogStore interface {
|
|
// InsertLog will insert the log at callID, overwriting if it previously
|
|
// existed.
|
|
InsertLog(ctx context.Context, appName, callID string, callLog io.Reader) error
|
|
|
|
// GetLog will return the log at callID, an error will be returned if the log
|
|
// cannot be found.
|
|
// TODO it would be nice if this were an io.Reader...
|
|
GetLog(ctx context.Context, appName, callID string) (*CallLog, error)
|
|
|
|
// DeleteLog will remove the log at callID, it will not return an error if
|
|
// the log does not exist before removal.
|
|
DeleteLog(ctx context.Context, appName, callID string) error
|
|
}
|