-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Create a basic Vertex Kernel with no functionalities
- Loading branch information
1 parent
cb0c249
commit be851a2
Showing
4 changed files
with
113 additions
and
10 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,26 @@ | ||
build: | ||
goos: | ||
- linux | ||
- darwin | ||
- windows | ||
goarch: | ||
- "386" | ||
- amd64 | ||
- arm | ||
- arm64 | ||
builds: | ||
- main: ./kernel | ||
id: "vertex-kernel" | ||
binary: vertex-kernel | ||
goos: | ||
- linux | ||
- darwin | ||
- windows | ||
goarch: | ||
- "386" | ||
- amd64 | ||
- arm | ||
- arm64 | ||
|
||
- main: . | ||
id: "vertex" | ||
binary: vertex | ||
goos: | ||
- linux | ||
- darwin | ||
- windows | ||
goarch: | ||
- "386" | ||
- amd64 | ||
- arm | ||
- arm64 |
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,14 @@ | ||
<component name="ProjectRunConfigurationManager"> | ||
<configuration default="false" name="Run Vertex Kernel" type="GoApplicationRunConfiguration" factoryName="Go Application"> | ||
<module name="Vertex" /> | ||
<working_directory value="$PROJECT_DIR$" /> | ||
<envs> | ||
<env name="DEBUG" value="1" /> | ||
</envs> | ||
<kind value="PACKAGE" /> | ||
<package value="github.com/vertex-center/vertex/kernel" /> | ||
<directory value="$PROJECT_DIR$" /> | ||
<filePath value="$PROJECT_DIR$/kernel/main.go" /> | ||
<method v="2" /> | ||
</configuration> | ||
</component> |
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,5 @@ | ||
package main | ||
|
||
func main() { | ||
return | ||
} |
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,68 @@ | ||
package router | ||
|
||
import ( | ||
"context" | ||
"net/http" | ||
"time" | ||
|
||
"github.com/gin-gonic/gin" | ||
"github.com/vertex-center/vertex/pkg/ginutils" | ||
) | ||
|
||
type KernelRouter struct { | ||
server *http.Server | ||
engine *gin.Engine | ||
} | ||
|
||
func NewKernelRouter() KernelRouter { | ||
gin.SetMode(gin.ReleaseMode) | ||
|
||
r := KernelRouter{ | ||
engine: gin.New(), | ||
} | ||
|
||
r.engine.Use(ginutils.ErrorHandler()) | ||
r.engine.Use(ginutils.Logger("KERNEL")) | ||
r.engine.Use(gin.Recovery()) | ||
r.engine.GET("/ping", handlePing) | ||
|
||
r.initAdapters() | ||
r.initServices() | ||
r.initAPIRoutes() | ||
|
||
return r | ||
} | ||
|
||
func (r *KernelRouter) Start() error { | ||
r.server = &http.Server{ | ||
Addr: ":6131", | ||
Handler: r.engine, | ||
} | ||
|
||
return r.server.ListenAndServe() | ||
} | ||
|
||
func (r *KernelRouter) Stop() error { | ||
ctx, cancel := context.WithTimeout(context.Background(), 2*time.Second) | ||
defer cancel() | ||
|
||
err := r.server.Shutdown(ctx) | ||
if err != nil { | ||
return err | ||
} | ||
|
||
r.server = nil | ||
return nil | ||
} | ||
|
||
func (r *KernelRouter) initAdapters() { | ||
// TODO: Implement | ||
} | ||
|
||
func (r *KernelRouter) initServices() { | ||
// TODO: Implement | ||
} | ||
|
||
func (r *KernelRouter) initAPIRoutes() { | ||
// TODO: Implement | ||
} |