Giter Club home page Giter Club logo

zepto's Introduction

Quickstart

Zepto is a lightweight framework for the development of microservices & web services in golang.

As an opinionated framework, zepto proposes to have a quick setup and with the greatest needs for the development of modern microservices. But not only that. It is a framework prepared for the development of complete web applications.

See below some of our features:

  • gRPC & HTTP support
  • Broker: Publish & Subscribe Events
    • Google Pub/Sub
    • Kafka (Comming soon...)
    • RabbitMQ (Comming soon)
  • Healthcheck
  • Gracefully Shutdown
  • Pretty & Plugabble Logger
  • Web Module:
    • Routing
    • Middlewares
    • Template Rendering
    • Debug Mode
    • Cookie
    • Session
    • File Upload
    • Static Files
    • Sass & JS building with webpack (dev and prod)
    • Error Handler
    • Testing Utilities

A Minimal Application

A minimal Zepto application looks something like this:

package main

import (
	"github.com/go-zepto/zepto"
	"github.com/gorilla/mux"
	"net/http"
)

func main() {
	z := zepto.NewZepto(
		zepto.Name("ms.hello.world"),
		zepto.Version("latest"),
	)

	r := mux.NewRouter()

	r.HandleFunc("/hello", func(w http.ResponseWriter, r *http.Request) {
		_, _ = w.Write([]byte("Hello, World!"))
	})

	// Setup HTTP Server
	z.SetupHTTP("0.0.0.0:8000", r)

	z.Start()
}

Instalation

With zepto you can easily create a project with the CLI tool:

go get -u github.com/go-zepto/zepto-cli/cmd/zepto

Create a Project

If you want to create a project, just run this command:

zepto new <PROJECT_TYPE> github.com/username/project

Available project types:

  • ms: It only includes the Zepto core like HTTP, gRPC, Healthcheck, Broker and all the basic structure to start the development and deployment of a microservice

  • web: It includes the zepto core and also the web module that includes routing, templating, cookie, session, file upload, static files, assets building (webpack).

Examples:

# ms
zepto new ms github.com/username/my-microservice

# web
zepto new web github.com/username/my-web

HTTP & gRPC

With zepto, you can easily set up an HTTP and/or gRPC server. Both can work simultaneously.

	// Setup gRPC Server
	z.SetupGRPC("0.0.0.0:9000", func(s *grpc.Server) {
		pb.RegisterTodosServer(s, handlers.NewGRPCHandler(svc))
	})

	// Setup HTTP Server
	z.SetupHTTP("0.0.0.0:8000", handlers.NewHTTPHandler(svc))

Broker/PubSub

Publish and Receive messages in an easy way. Zepto abstracts all the encode/decode logic behind sending and receiving messages from your broker.It is also extensible, as it has an interface layer that facilitates the creation of new brokers.

Broker Setup

// Setup Broker Provider (Google Pub/Sub)
z.SetupBroker(gcp.NewBroker(
    gcp.ProjectID("my-project"),
    gcp.TopicPrefix("dev.accounts."),
))

Subscribe to Messages

z.Broker().Subscribe("created", func(ctx context.Context, user *pb.User) {
    fmt.Println("User created account: " + user.Name)
})

Publish Messages

z.Broker().Publish(ctx, "created", user)

Logging

Zepto uses the Logrus library for Logging. It is extensible and customizable. You can define the log format you want, as well as which channel you want to log to. By default, our log looks like the one in the image below:

logger

zepto's People

Contributors

carlosstrand avatar

Watchers

James Cloos avatar

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.