Skip to content

Modules

Christopher McGregor edited this page Mar 19, 2018 · 35 revisions

Modules "building blocks" that integrate with Disgo are called services that implement the interface IService located in the disgo_commons repo.

IService interface

// IService
type IService interface {
    IsRunning() bool
    Go(waitGroup *sync.WaitGroup)
}
  • IsRunning() returns if the service is still running
  • Go(waitGroup *sync.WaitGroup) is the main entry point of the service

Sample Implementation:

The following is a shell implementation of the DAPoS service:

package core

import (
	"sync"
	log "github.com/sirupsen/logrus"
)

// DAPoSService
type DAPoSService struct {
	running bool
}

// NewDAPoSService
func NewDAPoSService() *DAPoSService {
	return &DAPoSService{
		running: false,
	}
}

// IsRunning
func (daposService *DAPoSService) IsRunning() bool {
	return daposService.running
}

// Go
func (daposService *DAPoSService) Go(waitGroup *sync.WaitGroup) {
	daposService.running = true
}
Clone this wiki locally