Skip to content

Commit

Permalink
Create a basic Vertex Kernel with no functionalities
Browse files Browse the repository at this point in the history
  • Loading branch information
quentinguidee committed Sep 26, 2023
1 parent cb0c249 commit be851a2
Show file tree
Hide file tree
Showing 4 changed files with 113 additions and 10 deletions.
36 changes: 26 additions & 10 deletions .goreleaser.yaml
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
14 changes: 14 additions & 0 deletions .run/Run Vertex Kernel.run.xml
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>
5 changes: 5 additions & 0 deletions kernel/main.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
package main

func main() {
return
}
68 changes: 68 additions & 0 deletions router/router_kernel.go
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
}

0 comments on commit be851a2

Please sign in to comment.