_ __ _ ___ ___ | | __ ___ / _ | _ __ __ _ _ __ _____ _____ _____ _ __ | | __ _ \ / __ | '_ \ / _ \ _____ | | _ |' __ / __ ` | '_ ` _ \ / _ \ \ /\ / / _ \| '__| |/ / | __/ (__| | | | (_) |_____| _| | | (_| | | | | | | __/\ V V / (_) | | | < \___|\___|_| | _ | \ ___ / | _ | | _ | \ __, _ _ - | | | _ | | _ | \ ___ | \ _ \ _ \ / ___ / | _ | | _ | \ _ \

Echo – Framework is a project framework for rapid development based on Echo

The installation

go get -u github.com/nelsonkti/echo-framework

Function description

  • Support for GORM, Logger Logging, JWT, Cron Timing Tasks, Redis, etc
  • Mysql database read/write separation, load balancing
  • Socket. IO communication protocol
  • NSQ message queue
  • Distributed deployment

Folder structure

  • The config file configures and initializes configuration data
  • Cron timed tasks
  • LIB is a library in daily use
  • Logic Business Logic
  • The main program starts the entry, which basically starts HTTP
  • Routes contain all the routing definitions for your application
  • Socket communication related code, Socket. IO communication protocol – based
  • Logic directory

    • HTTP includes controllers, middleware, and form requests, validators, and more

      • Controllers Controller Layer
      • Middleware middleware
      • Models model layer
      • The Repository business layer invokes the data access layer
      • Responses to return layer
      • The Services layer mainly deals with business logic
      • Validators form validators
    • MQ NSQ producers and consumers

      • Producer producers

Project introduction

Project Default Supportnsq,memcache,redis, if you don’t need it, you canmainComment the following code under the folder

memcache

// ConnectMemcache db.connectmemcache (config.memcache)

redis

Redis db.connectredis (config.redisip, config.redispassword, 0, "default")

nsq

/ / connect the redis go func () {defer helper. RecoverPanic () / / producer StartNsqProducer (config. NSQIP) mq.StartNsqServer(config.NSQIP, config.NSQConsumers) }()

By default, cron will not be started locally. If you need to start cron, you can remove the “if”

// Start the task if config.env! = "local" { cron.RegisterCrons(config.RedisIP, config.RedisPassword) }

Grom reads and writes separate Dbresolver

// Use the Write mode user.model ().clauses (dbresolver.write).first (&user).

Run the logic.

cd main
go run logic.go

Run the socket

cd main
go run socket.go

Environmental requirements

  • Go > = 1.13