-
Notifications
You must be signed in to change notification settings - Fork 45
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #262 from tigrisdata/main
Alpha release
- Loading branch information
Showing
13 changed files
with
152 additions
and
34 deletions.
There are no files selected for viewing
Submodule proto
updated
from 56ba26 to 778137
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
package middleware | ||
|
||
import "github.com/grpc-ecosystem/grpc-gateway/v2/runtime" | ||
|
||
const ( | ||
// RequestTimeoutHeader is an end-to-end request header that indicates the maximum time that a client is | ||
// prepared to await a response. The value of the header is in seconds. A client is allowed to send fractional | ||
// values. For ex, 0.1 means 100milliseconds. | ||
RequestTimeoutHeader = "Request-Timeout" | ||
) | ||
|
||
func CustomMatcher(key string) (string, bool) { | ||
switch key { | ||
case RequestTimeoutHeader: | ||
return key, true | ||
default: | ||
return runtime.DefaultHeaderMatcher(key) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
package middleware | ||
|
||
import ( | ||
"context" | ||
"testing" | ||
"time" | ||
|
||
"github.com/stretchr/testify/require" | ||
"google.golang.org/grpc/metadata" | ||
) | ||
|
||
func TestTimeout(t *testing.T) { | ||
ctx := context.Background() | ||
ctx = metadata.NewIncomingContext(ctx, metadata.New(map[string]string{ | ||
RequestTimeoutHeader: "0.2", | ||
})) | ||
ctx, _ = setDeadlineUsingHeader(ctx) | ||
deadline, ok := ctx.Deadline() | ||
require.True(t, ok) | ||
require.WithinDuration(t, time.Now().Add(200*time.Millisecond), deadline, 50*time.Millisecond) | ||
|
||
ctx = context.Background() | ||
ctx, _ = setDeadlineUsingHeader(ctx) | ||
_, ok = ctx.Deadline() | ||
require.False(t, ok) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.