mirror of
https://github.com/fnproject/fn.git
synced 2022-10-28 21:29:17 +03:00
Copy logs up to v2 endpoints (#1207)
Copies the log endpoints up to the V2 endpoints, in a similar way to the call endpoints. The main change is to when logs are inserted into S3. The signature of the function has been changed to take the whole call object, rather than just the app and call id's. This allows the function to switch between calls for Routes and those for Fns. Obviously this switching can be removed when v1 is removed. In the sql implementation it inserts with both appID and fnID, this allows the two get's to work, and the down grade of the migration. When the v1 logs are removed, the appId can be dropped. The log fetch test and error messages have been changed to be FnID specific.
This commit is contained in:
@@ -136,13 +136,20 @@ func (s3StoreProvider) New(ctx context.Context, u *url.URL) (models.LogStore, er
|
||||
return store, nil
|
||||
}
|
||||
|
||||
func (s *store) InsertLog(ctx context.Context, appID, callID string, callLog io.Reader) error {
|
||||
func (s *store) InsertLog(ctx context.Context, call *models.Call, callLog io.Reader) error {
|
||||
ctx, span := trace.StartSpan(ctx, "s3_insert_log")
|
||||
defer span.End()
|
||||
|
||||
// wrap original reader in a decorator to keep track of read bytes without buffering
|
||||
cr := &countingReader{r: callLog}
|
||||
objectName := logKey(appID, callID)
|
||||
|
||||
objectName := ""
|
||||
if call.FnID != "" {
|
||||
objectName = logKey(call.FnID, call.ID)
|
||||
} else {
|
||||
objectName = logKey(call.AppID, call.ID)
|
||||
}
|
||||
|
||||
params := &s3manager.UploadInput{
|
||||
Bucket: aws.String(s.bucket),
|
||||
Key: aws.String(objectName),
|
||||
@@ -317,10 +324,6 @@ func logKey(appID, callID string) string {
|
||||
return logKeyPrefix + appID + "/" + callID
|
||||
}
|
||||
|
||||
func logKey2(callID string) string {
|
||||
return logKeyPrefix + callID
|
||||
}
|
||||
|
||||
// GetCalls1 returns a list of calls that satisfy the given CallFilter. If no
|
||||
// calls exist, an empty list and a nil error are returned.
|
||||
// NOTE: this relies on call ids being lexicographically sortable and <= 16 byte
|
||||
|
||||
Reference in New Issue
Block a user