Coder Social home page Coder Social logo

gemini's Introduction

Go Report Card GitHub

gemini

Introduction

GEMINI is a microservice framework

Quick Start

package main

import (
    _ "demo/schedule"
    _ "demo/task"
    
    
    "os"
    "demo/services"

    "github.com/Jarnpher553/gemini/config"
    "github.com/Jarnpher553/gemini/redis"
    "github.com/Jarnpher553/gemini/repo"
    "github.com/Jarnpher553/gemini/router"
    "github.com/Jarnpher553/gemini/scheduler"
    "github.com/Jarnpher553/gemini/server"
    "github.com/Jarnpher553/gemini/service"
    "github.com/Jarnpher553/gemini/task"
    "github.com/Jarnpher553/gemini/task/delay"
)

func main() {
    env := config.DeployEnv(os.Args)
    
    // 获取对应项的配置
    serverCf := config.Conf().Sub("server")
    mysqlCf := config.Conf().Sub("mysql")
    redisCf := config.Conf().Sub("redis")
    
    // 数据库实例
    db := repo.New(repo.DbName(mysqlCf.GetString("dbName")), repo.Addr(mysqlCf.GetString("addr")), repo.Pwd(mysqlCf.GetString("password")), repo.UserName(mysqlCf.GetString("username")), repo.LogMode(false))
    rd := redis.New(redis.Pwd(redisCf.GetString("password")), redis.PoolSize(redisCf.GetInt("poolSize")), redis.DB(redisCf.GetInt("db")), redis.Addr(redisCf.GetString("addr")))
    
    
    // 实例化服务
    userService := service.NewService(&services.UserService{}, service.Repository(db), service.RedisClient(rd))
    
    scheduler.Bind(scheduler.Repo(db), scheduler.Redis(rd))
    delay.Bind(true, task.Redis(rd), task.Repo(db))
    
    // 实例化路由
    r := router.New()
    // 将服务注册进路由
    r.Assign(userService)
    
    // 实例化服务器
    srv := server.Default(server.Name("demo"), server.Env(env), server.RunMode(serverCf.GetString("runMode")), server.Router(r), server.Addr(serverCf.GetString("addr")))
    
    // 运行服务器
    srv.Run()
}

gemini's People

Contributors

grasscy avatar jarnpher553 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

Forkers

grasscy

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.