-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
144 changed files
with
8,474 additions
and
59 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
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion
2
sail/examples/mirc/auto/api/v3/site.go → sail/examples/auto/api/v3/site.go
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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,27 @@ | ||
// Copyright 2024 Michael Li <[email protected]>. All rights reserved. | ||
// Use of this source code is governed by Apache License 2.0 that | ||
// can be found in the LICENSE file. | ||
|
||
package migrate | ||
|
||
import ( | ||
"fmt" | ||
|
||
"github.com/alimy/mir/sail/mir-example/v4/cmd" | ||
"github.com/spf13/cobra" | ||
) | ||
|
||
func init() { | ||
migrateCmd := &cobra.Command{ | ||
Use: "migrate", | ||
Short: "migrate database data", | ||
Long: "miegrate database data when mir-examples upgrade", | ||
Run: migrateRun, | ||
} | ||
cmd.Register(migrateCmd) | ||
} | ||
|
||
func migrateRun(_cmd *cobra.Command, _args []string) { | ||
// TODO: add some logic for migrate cmd feature | ||
fmt.Println("sorry, this feature is not implemented yet.") | ||
} |
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,36 @@ | ||
// Copyright 2024 Michael Li <[email protected]>. All rights reserved. | ||
// Use of this source code is governed by Apache License 2.0 that | ||
// can be found in the LICENSE file. | ||
|
||
package cmd | ||
|
||
import ( | ||
"github.com/spf13/cobra" | ||
) | ||
|
||
var ( | ||
rootCmd = &cobra.Command{ | ||
Use: "mir-example", | ||
Short: `an artistic "twitter like" community`, | ||
Long: `an artistic "twitter like" community`, | ||
} | ||
) | ||
|
||
// Setup set root command name,short-describe, long-describe | ||
// return &cobra.Command to custom other options | ||
func Setup(use, short, long string) *cobra.Command { | ||
rootCmd.Use = use | ||
rootCmd.Short = short | ||
rootCmd.Long = long | ||
return rootCmd | ||
} | ||
|
||
// Register add sub-command | ||
func Register(cmd *cobra.Command) { | ||
rootCmd.AddCommand(cmd) | ||
} | ||
|
||
// Execute start application | ||
func Execute() { | ||
rootCmd.Execute() | ||
} |
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,65 @@ | ||
// Copyright 2024 Michael Li <[email protected]>. All rights reserved. | ||
// Use of this source code is governed by Apache License 2.0 that | ||
// can be found in the LICENSE file. | ||
|
||
package serve | ||
|
||
import ( | ||
"fmt" | ||
"log" | ||
"os" | ||
"os/signal" | ||
"syscall" | ||
|
||
"github.com/alimy/mir/sail/mir-example/v4/cmd" | ||
"github.com/alimy/mir/sail/mir-example/v4/internal/service" | ||
|
||
"github.com/fatih/color" | ||
"github.com/sourcegraph/conc" | ||
"github.com/spf13/cobra" | ||
"go.uber.org/automaxprocs/maxprocs" | ||
) | ||
|
||
var ( | ||
noDefaultFeatures bool | ||
features []string | ||
) | ||
|
||
func init() { | ||
serveCmd := &cobra.Command{ | ||
Use: "serve", | ||
Short: "start mir-example server", | ||
Long: "start mir-example server", | ||
Run: serveRun, | ||
} | ||
|
||
serveCmd.Flags().BoolVar(&noDefaultFeatures, "no-default-features", false, "whether not use default features") | ||
serveCmd.Flags().StringSliceVarP(&features, "features", "f", []string{}, "use special features") | ||
|
||
cmd.Register(serveCmd) | ||
} | ||
|
||
func serveRun(_cmd *cobra.Command, _args []string) { | ||
// set maxprocs automatic | ||
maxprocs.Set(maxprocs.Logger(log.Printf)) | ||
|
||
runtime := service.NewRuntime() | ||
|
||
// start services | ||
wg := conc.NewWaitGroup() | ||
fmt.Fprintf(color.Output, "\nstarting run service...\n\n") | ||
runtime.Start(wg) | ||
|
||
// graceful stop services | ||
wg.Go(func() { | ||
quit := make(chan os.Signal, 1) | ||
// kill (no param) default send syscall.SIGTERM | ||
// kill -2 is syscall.SIGINT | ||
// kill -9 is syscall.SIGKILL but can't be catch, so don't need add it | ||
signal.Notify(quit, syscall.SIGINT, syscall.SIGTERM) | ||
<-quit | ||
fmt.Fprintf(color.Output, "\nshutting down server...\n\n") | ||
runtime.Stop() | ||
}) | ||
wg.Wait() | ||
} |
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 @@ | ||
// Copyright 2024 Michael Li <[email protected]>. All rights reserved. | ||
// Use of this source code is governed by Apache License 2.0 that | ||
// can be found in the LICENSE file. | ||
|
||
package cmd | ||
|
||
import ( | ||
"fmt" | ||
|
||
"github.com/alimy/mir/sail/mir-example/v4/internal/conf" | ||
"github.com/spf13/cobra" | ||
) | ||
|
||
func init() { | ||
versionCmd := &cobra.Command{ | ||
Use: "version", | ||
Short: "show version information", | ||
Long: "show version information", | ||
Run: versionRun, | ||
} | ||
Register(versionCmd) | ||
} | ||
|
||
func versionRun(_cmd *cobra.Command, _args []string) { | ||
fmt.Println(conf.VersionInfo()) | ||
} |
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,4 @@ | ||
## 开发文档 | ||
本目录包含一些开发者文档。 | ||
|
||
* [openapi](openapi): api相关文档 |
Large diffs are not rendered by default.
Oops, something went wrong.
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,21 @@ | ||
// Copyright 2024 Michael Li <[email protected]>. All rights reserved. | ||
// Use of this source code is governed by Apache License 2.0 that | ||
// can be found in the LICENSE file. | ||
|
||
//go:build docs | ||
// +build docs | ||
|
||
package openapi | ||
|
||
import ( | ||
"embed" | ||
"net/http" | ||
) | ||
|
||
//go:embed index.html openapi.json **/* | ||
var files embed.FS | ||
|
||
// NewFileSystem get an embed static assets http.FileSystem instance. | ||
func NewFileSystem() http.FileSystem { | ||
return http.FS(files) | ||
} |
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,21 @@ | ||
<!DOCTYPE html> | ||
<!-- Important: must specify --> | ||
<html> | ||
<head> | ||
<meta charset="utf-8" /> | ||
<link rel="icon" href="/favicon.ico" /> | ||
<title>paopao-ce develop documents</title> | ||
<!-- Important: rapi-doc uses utf8 characters --> | ||
<script | ||
type="module" | ||
src="/docs/openapi/assets/rapidoc-min.js" | ||
></script> | ||
</head> | ||
<body> | ||
<rapi-doc | ||
spec-url="/docs/openapi/openapi.json" | ||
render-style="read" | ||
> | ||
</rapi-doc> | ||
</body> | ||
</html> |
Oops, something went wrong.