-
Notifications
You must be signed in to change notification settings - Fork 504
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
add filter WasmHost (close #1) #116
Merged
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
ec6a684
add wasm filter (close #1)
localvar 093f67b
[wasm] update according to comment
localvar 7749885
update according to review comments
localvar 5fbc839
add status
localvar 0463813
fix a bug and make the case of 'wasm` consistent
localvar f0ec2b9
rename WasmFilter to WasmHost
localvar File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -22,6 +22,18 @@ endif | |
# Build Flags | ||
GO_LD_FLAGS= "-s -w -X github.com/megaease/easegress/pkg/version.RELEASE=${RELEASE} -X github.com/megaease/easegress/pkg/version.COMMIT=${GIT_COMMIT} -X github.com/megaease/easegress/pkg/version.REPO=${GIT_REPO_INFO}" | ||
|
||
# Cgo is disabled by default | ||
ENABLE_CGO= CGO_ENABLED=0 | ||
|
||
# Check Go build tags, the tags are from command line of make | ||
ifdef GOTAGS | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Actually, I don't think it's a big deal to include more than 20MB in EG with wasm. I think it brings more concern in compilation, which gives more confusing stuff to developers, operators. |
||
GO_BUILD_TAGS= -tags ${GOTAGS} | ||
# Must enable Cgo when wasmhost is included | ||
ifeq ($(findstring wasmhost,${GOTAGS}), wasmhost) | ||
ENABLE_CGO= CGO_ENABLED=1 | ||
endif | ||
endif | ||
|
||
# Targets | ||
TARGET_SERVER=${RELEASE_DIR}/easegress-server | ||
TARGET_CLIENT=${RELEASE_DIR}/egctl | ||
|
@@ -38,7 +50,7 @@ build_client: | |
build_server: | ||
@echo "build server" | ||
cd ${MKFILE_DIR} && \ | ||
CGO_ENABLED=0 go build -v -trimpath -ldflags ${GO_LD_FLAGS} \ | ||
${ENABLE_CGO} go build ${GO_BUILD_TAGS} -v -trimpath -ldflags ${GO_LD_FLAGS} \ | ||
-o ${TARGET_SERVER} ${MKFILE_DIR}cmd/server | ||
|
||
dev_build: dev_build_client dev_build_server | ||
|
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
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,53 @@ | ||
// +build wasmhost | ||
|
||
/* | ||
* Copyright (c) 2017, MegaEase | ||
* All rights reserved. | ||
* | ||
* 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. | ||
*/ | ||
|
||
package api | ||
|
||
import ( | ||
"fmt" | ||
"net/http" | ||
"time" | ||
) | ||
|
||
func (s *Server) postWasmCodeUpdateEvent() string { | ||
key := s.cluster.Layout().WasmCodeEvent() | ||
value := time.Now().Format(time.RFC3339Nano) | ||
if e := s.cluster.Put(key, value); e != nil { | ||
ClusterPanic(e) | ||
} | ||
return value | ||
} | ||
|
||
func appendWasmAPI(s *Server, group *APIGroup) { | ||
entry := &APIEntry{ | ||
Path: "/wasm/code", | ||
Method: "POST", | ||
Handler: func(w http.ResponseWriter, r *http.Request) { | ||
v := s.postWasmCodeUpdateEvent() | ||
w.Header().Set("Content-Type", "text/plain") | ||
fmt.Fprintf(w, "wasm code update event posted at: %s\n", v) | ||
}, | ||
} | ||
|
||
group.Entries = append(group.Entries, entry) | ||
} | ||
|
||
func init() { | ||
appendAddonAPIs = append(appendAddonAPIs, appendWasmAPI) | ||
} |
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,18 @@ | ||
/* | ||
* Copyright (c) 2017, MegaEase | ||
* All rights reserved. | ||
* | ||
* 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. | ||
*/ | ||
|
||
package wasmhost |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Check whether docker image with alpine runs correctly please.