Rename to Shezmu
This commit is contained in:
		
							parent
							
								
									c5f995035a
								
							
						
					
					
						commit
						bb750bf727
					
				@ -1,6 +1,6 @@
 | 
			
		||||
# Satan
 | 
			
		||||
# Shezmu
 | 
			
		||||
 | 
			
		||||
Satan is a daemon execution platform for Go apps.
 | 
			
		||||
Shezmu is a daemon execution platform for Go apps.
 | 
			
		||||
 | 
			
		||||
* What is a daemon execution platform?
 | 
			
		||||
* What does it provide?
 | 
			
		||||
 | 
			
		||||
@ -5,7 +5,7 @@ into the functions' first argument. Its main purpose is to hide common
 | 
			
		||||
unmarshalling code from each function implementation thus reducing
 | 
			
		||||
boilerplate and making package interaction code sexier.
 | 
			
		||||
 | 
			
		||||
[Documentation](https://godoc.org/github.com/localhots/satan/caller)
 | 
			
		||||
[Documentation](https://godoc.org/github.com/localhots/shezmu/caller)
 | 
			
		||||
 | 
			
		||||
### Example
 | 
			
		||||
 | 
			
		||||
@ -14,7 +14,7 @@ package main
 | 
			
		||||
 | 
			
		||||
import (
 | 
			
		||||
    "log"
 | 
			
		||||
    "github.com/localhots/satan/caller"
 | 
			
		||||
    "github.com/localhots/shezmu/caller"
 | 
			
		||||
    "github.com/path/to/package/messenger"
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
@ -37,7 +37,7 @@ Support code:
 | 
			
		||||
package messenger
 | 
			
		||||
 | 
			
		||||
import (
 | 
			
		||||
    "github.com/localhots/satan/caller"
 | 
			
		||||
    "github.com/localhots/shezmu/caller"
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
type item struct {
 | 
			
		||||
 | 
			
		||||
@ -1,4 +1,4 @@
 | 
			
		||||
package satan
 | 
			
		||||
package shezmu
 | 
			
		||||
 | 
			
		||||
import (
 | 
			
		||||
	"errors"
 | 
			
		||||
@ -7,7 +7,7 @@ import (
 | 
			
		||||
	"time"
 | 
			
		||||
 | 
			
		||||
	"github.com/juju/ratelimit"
 | 
			
		||||
	"github.com/localhots/satan/caller"
 | 
			
		||||
	"github.com/localhots/shezmu/caller"
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
// Daemon is the interface that contains a set of methods required to be
 | 
			
		||||
@ -155,14 +155,14 @@ func (d *BaseDaemon) Continue() bool {
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// Log logs values using satan.Logger.Println function.
 | 
			
		||||
// Log logs values using shezmu.Logger.Println function.
 | 
			
		||||
func (d *BaseDaemon) Log(v ...interface{}) {
 | 
			
		||||
	if d.logger != nil {
 | 
			
		||||
		d.logger.Println(v...)
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// Logf logs values using satan.Logger.Printf function.
 | 
			
		||||
// Logf logs values using shezmu.Logger.Printf function.
 | 
			
		||||
func (d *BaseDaemon) Logf(format string, v ...interface{}) {
 | 
			
		||||
	if d.logger != nil {
 | 
			
		||||
		d.logger.Printf(format, v...)
 | 
			
		||||
 | 
			
		||||
@ -1,5 +1,5 @@
 | 
			
		||||
{
 | 
			
		||||
    "name": "satan",
 | 
			
		||||
    "name": "shezmu",
 | 
			
		||||
    "private": true,
 | 
			
		||||
    "dependencies": {
 | 
			
		||||
        "react": "0.14.0",
 | 
			
		||||
 | 
			
		||||
@ -1,3 +1,3 @@
 | 
			
		||||
# Satan example application
 | 
			
		||||
# Shezmu example application
 | 
			
		||||
 | 
			
		||||
Describe the app here.
 | 
			
		||||
 | 
			
		||||
@ -4,12 +4,12 @@ import (
 | 
			
		||||
	"math/rand"
 | 
			
		||||
	"time"
 | 
			
		||||
 | 
			
		||||
	"github.com/localhots/satan"
 | 
			
		||||
	"github.com/localhots/shezmu"
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
// NumberPrinter is a daemon that prints numbers once in a while.
 | 
			
		||||
type NumberPrinter struct {
 | 
			
		||||
	satan.BaseDaemon
 | 
			
		||||
	shezmu.BaseDaemon
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// Startup sets up panic handler and starts enqueuing number printing jobs.
 | 
			
		||||
@ -33,7 +33,7 @@ func (n *NumberPrinter) generateNumbers() {
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (n *NumberPrinter) makeActor(num int) satan.Actor {
 | 
			
		||||
func (n *NumberPrinter) makeActor(num int) shezmu.Actor {
 | 
			
		||||
	return func() {
 | 
			
		||||
		n.Log("Number printer says:", num)
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@ -3,12 +3,12 @@ package daemons
 | 
			
		||||
import (
 | 
			
		||||
	"time"
 | 
			
		||||
 | 
			
		||||
	"github.com/localhots/satan"
 | 
			
		||||
	"github.com/localhots/shezmu"
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
// PriceConsumer consumes price update messages and prints them to the console.
 | 
			
		||||
type PriceConsumer struct {
 | 
			
		||||
	satan.BaseDaemon
 | 
			
		||||
	shezmu.BaseDaemon
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// PriceUpdate describes a price update message.
 | 
			
		||||
 | 
			
		||||
@ -9,7 +9,7 @@ import (
 | 
			
		||||
	"sync"
 | 
			
		||||
 | 
			
		||||
	"github.com/Shopify/sarama"
 | 
			
		||||
	"github.com/localhots/satan"
 | 
			
		||||
	"github.com/localhots/shezmu"
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
// ConsumerState contains data that is required to create a Kafka consumer.
 | 
			
		||||
@ -18,10 +18,10 @@ type ConsumerState struct {
 | 
			
		||||
	Offset    int64 `json:"offset"`
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// Subscriber is a dummy structure that implements satan.Subscriber interface.
 | 
			
		||||
// Subscriber is a dummy structure that implements shezmu.Subscriber interface.
 | 
			
		||||
type Subscriber struct{}
 | 
			
		||||
 | 
			
		||||
// Stream is an implementation of satan.Stremer for Kafka messaging queue.
 | 
			
		||||
// Stream is an implementation of shezmu.Stremer for Kafka messaging queue.
 | 
			
		||||
type Stream struct {
 | 
			
		||||
	messages chan []byte
 | 
			
		||||
	shutdown chan struct{}
 | 
			
		||||
@ -44,7 +44,7 @@ func Initialize(brokers []string) {
 | 
			
		||||
	defer log.Println("Kafka is initialized")
 | 
			
		||||
 | 
			
		||||
	conf := sarama.NewConfig()
 | 
			
		||||
	conf.ClientID = "Satan Example"
 | 
			
		||||
	conf.ClientID = "Shezmu Example"
 | 
			
		||||
 | 
			
		||||
	var err error
 | 
			
		||||
	if kafkaClient, err = sarama.NewClient(brokers, conf); err != nil {
 | 
			
		||||
@ -70,8 +70,8 @@ func Shutdown() {
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// Subscribe creates a satan.Streamer implementation for Kafka messaging queue.
 | 
			
		||||
func (s Subscriber) Subscribe(consumer, topic string) satan.Streamer {
 | 
			
		||||
// Subscribe creates a shezmu.Streamer implementation for Kafka messaging queue.
 | 
			
		||||
func (s Subscriber) Subscribe(consumer, topic string) shezmu.Streamer {
 | 
			
		||||
	c, ok := consumers[consumer]
 | 
			
		||||
	if !ok {
 | 
			
		||||
		panic(fmt.Errorf("Consumer %q has no config", consumer))
 | 
			
		||||
 | 
			
		||||
@ -7,11 +7,11 @@ import (
 | 
			
		||||
	"strings"
 | 
			
		||||
	"syscall"
 | 
			
		||||
 | 
			
		||||
	"github.com/localhots/satan"
 | 
			
		||||
	"github.com/localhots/satan/example/daemons"
 | 
			
		||||
	"github.com/localhots/satan/example/kafka"
 | 
			
		||||
	"github.com/localhots/satan/server"
 | 
			
		||||
	"github.com/localhots/satan/stats"
 | 
			
		||||
	"github.com/localhots/shezmu"
 | 
			
		||||
	"github.com/localhots/shezmu/example/daemons"
 | 
			
		||||
	"github.com/localhots/shezmu/example/kafka"
 | 
			
		||||
	"github.com/localhots/shezmu/server"
 | 
			
		||||
	"github.com/localhots/shezmu/stats"
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
func main() {
 | 
			
		||||
@ -30,7 +30,7 @@ func main() {
 | 
			
		||||
	server := server.New(6464, statsServer)
 | 
			
		||||
	server.Start()
 | 
			
		||||
 | 
			
		||||
	s := satan.Summon()
 | 
			
		||||
	s := shezmu.Summon()
 | 
			
		||||
	s.Subscriber = kafka.Subscriber{}
 | 
			
		||||
	s.DaemonStats = stats.NewGroup(statsLogger, statsServer)
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@ -4,7 +4,7 @@ import (
 | 
			
		||||
	"fmt"
 | 
			
		||||
	"net/http"
 | 
			
		||||
 | 
			
		||||
	"github.com/localhots/satan/stats"
 | 
			
		||||
	"github.com/localhots/shezmu/stats"
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
type Server struct {
 | 
			
		||||
 | 
			
		||||
@ -1,4 +1,4 @@
 | 
			
		||||
package satan
 | 
			
		||||
package shezmu
 | 
			
		||||
 | 
			
		||||
import (
 | 
			
		||||
	"fmt"
 | 
			
		||||
@ -8,11 +8,11 @@ import (
 | 
			
		||||
	"sync"
 | 
			
		||||
	"time"
 | 
			
		||||
 | 
			
		||||
	"github.com/localhots/satan/stats"
 | 
			
		||||
	"github.com/localhots/shezmu/stats"
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
// Satan is the master daemon.
 | 
			
		||||
type Satan struct {
 | 
			
		||||
// Shezmu is the master daemon.
 | 
			
		||||
type Shezmu struct {
 | 
			
		||||
	Subscriber  Subscriber
 | 
			
		||||
	Publisher   Publisher
 | 
			
		||||
	DaemonStats stats.Publisher
 | 
			
		||||
@ -71,9 +71,9 @@ const (
 | 
			
		||||
	DefaultNumWorkers = 100
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
// Summon creates a new instance of Satan.
 | 
			
		||||
func Summon() *Satan {
 | 
			
		||||
	return &Satan{
 | 
			
		||||
// Summon creates a new instance of Shezmu.
 | 
			
		||||
func Summon() *Shezmu {
 | 
			
		||||
	return &Shezmu{
 | 
			
		||||
		DaemonStats:     &stats.Void{},
 | 
			
		||||
		Logger:          log.New(os.Stdout, "[daemons] ", log.LstdFlags),
 | 
			
		||||
		NumWorkers:      DefaultNumWorkers,
 | 
			
		||||
@ -85,7 +85,7 @@ func Summon() *Satan {
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// AddDaemon adds a new daemon.
 | 
			
		||||
func (s *Satan) AddDaemon(d Daemon) {
 | 
			
		||||
func (s *Shezmu) AddDaemon(d Daemon) {
 | 
			
		||||
	base := d.base()
 | 
			
		||||
	base.self = d
 | 
			
		||||
	base.subscriber = s.Subscriber
 | 
			
		||||
@ -99,7 +99,7 @@ func (s *Satan) AddDaemon(d Daemon) {
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// StartDaemons starts all registered daemons.
 | 
			
		||||
func (s *Satan) StartDaemons() {
 | 
			
		||||
func (s *Shezmu) StartDaemons() {
 | 
			
		||||
	s.Logger.Printf("Starting %d workers", s.NumWorkers)
 | 
			
		||||
	for i := 0; i < s.NumWorkers; i++ {
 | 
			
		||||
		go s.runWorker()
 | 
			
		||||
@ -107,7 +107,7 @@ func (s *Satan) StartDaemons() {
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// StopDaemons stops all running daemons.
 | 
			
		||||
func (s *Satan) StopDaemons() {
 | 
			
		||||
func (s *Shezmu) StopDaemons() {
 | 
			
		||||
	close(s.shutdownSystem)
 | 
			
		||||
	for _, d := range s.daemons {
 | 
			
		||||
		d.Shutdown()
 | 
			
		||||
@ -121,7 +121,7 @@ func (s *Satan) StopDaemons() {
 | 
			
		||||
	fmt.Println(s.runtimeStats.Fetch(stats.Latency))
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (s *Satan) runWorker() {
 | 
			
		||||
func (s *Shezmu) runWorker() {
 | 
			
		||||
	s.wgWorkers.Add(1)
 | 
			
		||||
	defer s.wgWorkers.Done()
 | 
			
		||||
	defer func() {
 | 
			
		||||
@ -142,7 +142,7 @@ func (s *Satan) runWorker() {
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (s *Satan) processTask(t *task) {
 | 
			
		||||
func (s *Shezmu) processTask(t *task) {
 | 
			
		||||
	dur := time.Now().Sub(t.createdAt)
 | 
			
		||||
	s.runtimeStats.Add(stats.Latency, dur)
 | 
			
		||||
 | 
			
		||||
@ -153,7 +153,7 @@ func (s *Satan) processTask(t *task) {
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (s *Satan) processSystemTask(t *task) {
 | 
			
		||||
func (s *Shezmu) processSystemTask(t *task) {
 | 
			
		||||
	// Abort starting a system task if shutdown was already called. Otherwise
 | 
			
		||||
	// incrementing a wait group counter will cause a panic. This should be an
 | 
			
		||||
	// extremely rare scenario when a system task crashes and tries to restart
 | 
			
		||||
@ -182,7 +182,7 @@ func (s *Satan) processSystemTask(t *task) {
 | 
			
		||||
	t.actor() // <--- ACTION STARTS HERE
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (s *Satan) processGeneralTask(t *task) {
 | 
			
		||||
func (s *Shezmu) processGeneralTask(t *task) {
 | 
			
		||||
	defer func() {
 | 
			
		||||
		if err := recover(); err != nil {
 | 
			
		||||
			s.DaemonStats.Error(t.daemon.base().String())
 | 
			
		||||
@ -7,7 +7,7 @@ def main():
 | 
			
		||||
    source = open(".gitmodules").read()
 | 
			
		||||
    paths = re.findall(r"path = (.*)", source)
 | 
			
		||||
 | 
			
		||||
    print("github.com/localhots/satan {}".format(path_sha1(".")))
 | 
			
		||||
    print("github.com/localhots/shezmu {}".format(path_sha1(".")))
 | 
			
		||||
    for path in paths:
 | 
			
		||||
        print("{} {}".format(path[7:], path_sha1(path)))
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user