nuMicro

package module
v0.0.0-...-a021f40 Latest Latest
Warning

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

Go to latest
Published: May 15, 2020 License: MIT Imports: 3 Imported by: 0

README

nuMicro

####A micro services framework for event driven distributed systems.

GoDoc

https://pkg.go.dev/github.com/Just4Ease/nuMicro

Installation

go get github.com/Just4Ease/nuMicro

Usage

The Init nuMicro.Init is a an entry point into starting the Microservice.

package main

import (

"fmt"


"github.com/Just4Ease/nuMicro"
"github.com/Just4Ease/nuMicro/broker"
) 
var serviceName string

func main()  {
  serviceName = "UsersSVC" // The name of your microservice here.
  nuMicro.Init(serviceName, EventsHandle, ActionsHandle)
}

func BuildChannelName(channelName string) string {
    s := fmt.Sprintf("%s.%s", serviceName, channelName)
    return s
}


func EventsHandle(serviceName string)  {
 // Handle your events here for pub/sub pattern
}

func ActionsHandle(serviceName string)  {
 // Handle your actions here for pub/sub pattern
_, _ = broker.Respond(BuildChannelName("Contact"), func(event broker.Event) interface{} {
        // Here, this could be a function that processes something to respond when it is being called on the contact channel.
		result := make(map[string]string)
		result["username"] = "just4ease"
		result["email"] = "justicenefe@gmail.com"
		result["phone"] = "+2347056031137"
		result["website"] = "https://justicenefe.com"

		return result
	}, nil)
}

#NOTE:

  • nuMicro uses NATS.io as it's broker but you can extend and configure your message broker

TODO:

  • Mount service discovery

  • Mount the probe, the probe is used to get an auto-documentation for each action call in the microservice. It would return the input argument and output response sample for each action call so that the "client" can send in the right parameters.

  • Use msgpack for internal service/client to service/client encoding and decoding of messages. It's faster than JSON, BSON and Gob, gateways can use whatever they desire.

  • Enable auto scaling ( Still an experimental feature right now. )

  • Embed internal NATS server for fallback if a cloud nats goes down, and republish it's public NATS address so that it can be discoverable within 10 - 100ms without noticeable downtime.

  • Enable the circuit breaker

  • Enable an extra layer for idempotence

License

The MIT License (MIT)

See LICENSE for details.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Init

func Init(serviceName string, eventsHandler mountServices, actionHandler mountServices, opts ...broker.Option)

*

  • Entry point into nuMicro
  • The ```Init``` method takes a service name and the handler for all subscription. *
  • param: string serviceName
  • param: mountServices eventsHandler
  • param: mountServices actionHandler

Types

This section is empty.

Directories

Path Synopsis
Package broker is an interface used for asynchronous messaging
Package broker is an interface used for asynchronous messaging
nats
Package nats provides a NATS broker
Package nats provides a NATS broker
Package codec is an interface for encoding messages
Package codec is an interface for encoding messages
bytes
Package bytes provides a bytes codec which does not encode or decode anything
Package bytes provides a bytes codec which does not encode or decode anything
json
Package json provides a json codec
Package json provides a json codec
text
Package text reads any text/* content-type
Package text reads any text/* content-type
debug
log
Package log provides debug logging
Package log provides debug logging
Package store is an interface for distribute data storage.
Package store is an interface for distribute data storage.
memory
Package memory is a in-memory store store
Package memory is a in-memory store store
utils
backoff
Package backoff provides backoff functionality
Package backoff provides backoff functionality
log
Package log is a global internal logger
Package log is a global internal logger
tls

Jump to

Keyboard shortcuts

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