woocoo

package module
v0.7.4 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 30, 2026 License: Apache-2.0 Imports: 10 Imported by: 24

README

WooCoo

Language codecov Go Report Card Build Status Release GoDoc

Introduction

WooCoo is an application development framework and toolkit written in GO(Golang). It is easy to develop WebApi applications or RPC services.

WooCoo mainly plays a role of adhesive, and its core components are from other open source projects. The current features are as follows:

Features

  • component configurable,easy to split multi environments
  • logger and rotate support. Detail,
  • OpenTelemetry support. Detail
  • built-in web router,supports GraphQL.
  • built-in grpc server and easy to use grpc client.
  • JWT-based validation
  • microservice registry and discovery:
    • etcdv3: register and discovery services
    • Polaris: service discovery and governance

Tools

  • woco-cli: command line tool, include feature:

    • generate code support: Ent
    • server code generator for openapi 3.0 spec. seeOpenApi3 Generator

Work With

examples

woocoo examples

others:

contact:

  • QQ: 21997272

Thanks

image

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func MiniApp added in v0.2.6

func MiniApp(ctx context.Context, timeout time.Duration, servers ...Server) (run, stop func() error)

MiniApp provides a simplified way to run multiple servers with lifecycle management. It returns a run function that starts all servers and a stop function to gracefully shut them down. If timeout > 0, the context will be cancelled after the timeout duration.

Types

type App

type App struct {
	// contains filtered or unexported fields
}

App is the application with a universal mechanism to manage goroutine lifecycles.

func New

func New(opts ...Option) *App

New creates an application by Option.

func (*App) AppConfiguration

func (a *App) AppConfiguration() *conf.AppConfiguration

func (*App) RegisterServer

func (a *App) RegisterServer(servers ...Server)

func (*App) Run

func (a *App) Run() error

Run all Server concurrently. Run returns when all Server have exited. Run returns the first non-nil error (if any) from them.

func (*App) Stop

func (a *App) Stop() error

Stop the application.

func (*App) Sync added in v0.5.0

func (a *App) Sync() error

Sync calls some resources suck as logger flushing any buffered log entries. Applications should take care to call Sync before exiting.

type Group added in v0.7.4

type Group struct {
	// contains filtered or unexported fields
}

Group collects actors (functions) and runs them concurrently. When one actor (function) returns, all actors are interrupted. The zero value of a Group is useful.

func (*Group) Add added in v0.7.4

func (g *Group) Add(execute func() error, interrupt func(error)) *Group

Add an actor (function) to the group. Each actor must be pre-emptable by an interrupt function. That is, if interrupt is invoked, execute should return. Also, it must be safe to call interrupt even after execute has returned.

The first actor (function) to return interrupts all running actors. The error is passed to the interrupt functions, and is returned by Run.

func (*Group) Run added in v0.7.4

func (g *Group) Run() error

Run all actors (functions) concurrently. When the first actor returns, all others are interrupted. Run only returns when all actors have exited. Run returns the error returned by the first exiting actor.

type Option

type Option func(o *options)

func WithAppConfiguration

func WithAppConfiguration(cnf *conf.Configuration) Option

WithAppConfiguration set up the configuration of the web server by a configuration instance

func WithInterval added in v0.5.0

func WithInterval(interval time.Duration) Option

WithInterval controls the interval time for App starting every server with time.Sleep if servers have some dependencies.

type Server

type Server interface {
	Start(ctx context.Context) error
	Stop(ctx context.Context) error
}

Server is the interface that can run in App.

Directories

Path Synopsis
cmd
woco module
contrib
etcd module
gql module
opentelemetry module
polarismesh module
telemetry module
examples
hello-web module
pkg
gds
gds/timeinterval
Package timeinterval is time range data structure ,many trade system has this.
Package timeinterval is time range data structure ,many trade system has this.
log
rpc
test
web

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL