-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into feat/sentinel-plugin
- Loading branch information
Showing
45 changed files
with
377 additions
and
167 deletions.
There are no files selected for viewing
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
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,54 @@ | ||
// Copyright The HTNN Authors. | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
//go:build envoydev | ||
|
||
package filtermanager | ||
|
||
import ( | ||
capi "github.com/envoyproxy/envoy/contrib/golang/common/go/api" | ||
) | ||
|
||
const ( | ||
supportGettingHeadersOnLog = true | ||
) | ||
|
||
func (m *filterManager) OnLog(reqHdr capi.RequestHeaderMap, _ capi.RequestTrailerMap, rspHdr capi.ResponseHeaderMap, _ capi.ResponseTrailerMap) { | ||
if m.canSkipOnLog { | ||
return | ||
} | ||
|
||
m.hdrLock.Lock() | ||
if m.reqHdr == nil { | ||
m.reqHdr = &filterManagerRequestHeaderMap{ | ||
RequestHeaderMap: reqHdr, | ||
} | ||
} else { | ||
// In our benchmark BenchmarkFilterManagerRegular, reuse the request header wrapper is 5% faster than create a new one, | ||
// even the reusage requires holding the lock though it is running on fast path. | ||
h, _ := m.reqHdr.(*filterManagerRequestHeaderMap) | ||
h.RequestHeaderMap = reqHdr | ||
} | ||
m.hdrLock.Unlock() | ||
m.runOnLogPhase(m.reqHdr, rspHdr) | ||
} | ||
|
||
func wrapFilterManager(fm *filterManager) capi.StreamFilter { | ||
return fm | ||
} | ||
|
||
// This method is test only | ||
func unwrapFilterManager(wrapper capi.StreamFilter) *filterManager { | ||
return wrapper.(*filterManager) | ||
} |
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,64 @@ | ||
// Copyright The HTNN Authors. | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
//go:build !envoydev | ||
|
||
package filtermanager | ||
|
||
import ( | ||
capi "github.com/envoyproxy/envoy/contrib/golang/common/go/api" | ||
|
||
"mosn.io/htnn/api/pkg/filtermanager/api" | ||
) | ||
|
||
const ( | ||
supportGettingHeadersOnLog = false | ||
) | ||
|
||
func (m *filterManager) OnLog(_ capi.RequestHeaderMap, _ capi.RequestTrailerMap, _ capi.ResponseHeaderMap, _ capi.ResponseTrailerMap) { | ||
if m.canSkipOnLog { | ||
return | ||
} | ||
|
||
var reqHdr api.RequestHeaderMap | ||
m.hdrLock.Lock() | ||
reqHdr = m.reqHdr | ||
m.hdrLock.Unlock() | ||
var rspHdr api.ResponseHeaderMap | ||
m.hdrLock.Lock() | ||
rspHdr = m.rspHdr | ||
m.hdrLock.Unlock() | ||
|
||
m.runOnLogPhase(reqHdr, rspHdr) | ||
} | ||
|
||
type filterManagerWrapper struct { | ||
*filterManager | ||
} | ||
|
||
func (w *filterManagerWrapper) OnLog() { | ||
w.filterManager.OnLog(nil, nil, nil, nil) | ||
} | ||
|
||
// we will get rid of this wrapper once Envoy 1.32 is released | ||
|
||
func wrapFilterManager(fm *filterManager) capi.StreamFilter { | ||
return &filterManagerWrapper{fm} | ||
} | ||
|
||
// This method is test only | ||
func unwrapFilterManager(wrapper capi.StreamFilter) *filterManager { | ||
fmw, _ := wrapper.(*filterManagerWrapper) | ||
return fmw.filterManager | ||
} |
Oops, something went wrong.