Skip to content

Commit

Permalink
quick fix for stammered type names
Browse files Browse the repository at this point in the history
  • Loading branch information
johrstrom committed Oct 5, 2018
1 parent 0670405 commit 8491d00
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 17 deletions.
4 changes: 2 additions & 2 deletions cmd/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,14 +38,14 @@ func main() {
if err != nil {
cfg = &config.DefaultConfig
log := cfg.GetLogger("common")
log.Info("loaded default configs.")
log.WithError(err).Info("loaded default configs.")
}

dlsvr := server.NewDeadlineServer(cfg)

err = dlsvr.Start()
if err != nil {
log := cfg.GetLogger("common")
log.WithField("error", err).Error("server didn't start")
log.WithError(err).Error("server didn't start")
}
}
24 changes: 12 additions & 12 deletions schedule/manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,12 @@ import (
"github.com/sirupsen/logrus"
)

var manager *ScheduleManager
var manager *Manager
var once sync.Once
var log *logrus.Logger

// GetManagerInstance will return the singleton of the ScheduleManager object
func GetManagerInstance(cfg *config.Config) *ScheduleManager {
// GetManagerInstance will return the singleton of the Manager object
func GetManagerInstance(cfg *config.Config) *Manager {
once.Do(func() {
db, err := dao.NewScheduleDAO(cfg)
log = cfg.GetLogger("manager")
Expand All @@ -24,7 +24,7 @@ func GetManagerInstance(cfg *config.Config) *ScheduleManager {
log.WithError(err).Fatal("cannot load configs")
}

manager = &ScheduleManager{
manager = &Manager{
db: db,
rwLock: &sync.RWMutex{},
}
Expand All @@ -41,8 +41,8 @@ func GetManagerInstance(cfg *config.Config) *ScheduleManager {
}

// part of the initialization cycle, this function should only be called once per instance of the
// ScheduleManager. It is not likely thread safe at this time.
func (manager *ScheduleManager) loadAllSchedules() {
// Manager. It is not likely thread safe at this time.
func (manager *Manager) loadAllSchedules() {
log.Info("loading all schedules.")

blueprints, err := manager.db.LoadScheduleBlueprints()
Expand Down Expand Up @@ -84,7 +84,7 @@ func (manager *ScheduleManager) loadAllSchedules() {
}

// Update updates any schedule currently alive with the event that you pass in
func (manager *ScheduleManager) Update(e *com.Event) {
func (manager *Manager) Update(e *com.Event) {
manager.rwLock.Lock()
defer manager.rwLock.Unlock()

Expand All @@ -109,13 +109,13 @@ func (manager *ScheduleManager) Update(e *com.Event) {
}

// GetBlueprint gets a blueprint for a schedule given the name of the blueprint
func (manager *ScheduleManager) GetBlueprint(name string) (*com.ScheduleBlueprint, error) {
func (manager *Manager) GetBlueprint(name string) (*com.ScheduleBlueprint, error) {
return manager.db.GetByName(name)
}

// AddScheduleAndSave is just like AddSchedule but has the added benefit of saving the blueprint
// to some sort of persistance layer.
func (manager *ScheduleManager) AddScheduleAndSave(blueprint *com.ScheduleBlueprint) error {
func (manager *Manager) AddScheduleAndSave(blueprint *com.ScheduleBlueprint) error {
// TODO rollback the save if the other errors out
if err := manager.db.Save(blueprint); err != nil {
return err
Expand All @@ -129,7 +129,7 @@ func (manager *ScheduleManager) AddScheduleAndSave(blueprint *com.ScheduleBluepr
// AddSchedule adds the schedule to the current list of schedules. If the schedule's start time
// it will become live and the manager will start to evaluate it. Otherwise it will be scheduled
// to become live at that time
func (manager *ScheduleManager) AddSchedule(blueprint com.ScheduleBlueprint) error {
func (manager *Manager) AddSchedule(blueprint com.ScheduleBlueprint) error {
var startTime time.Time
var timing time.Duration
var nextTime time.Duration
Expand Down Expand Up @@ -174,7 +174,7 @@ func (manager *ScheduleManager) AddSchedule(blueprint com.ScheduleBlueprint) err

// GetSchedule gets the current running schedule by the given name. If it exists, it'll
// return it, if not, it will return nil.
func (manager *ScheduleManager) GetSchedule(name string) *Schedule {
func (manager *Manager) GetSchedule(name string) *Schedule {
manager.rwLock.RLock()
defer manager.rwLock.RUnlock()
var s *Schedule
Expand Down Expand Up @@ -221,7 +221,7 @@ func timingToDuration(timing string) (time.Duration, error) {
return time.ParseDuration(timing)
}

func (manager *ScheduleManager) evaluateAllSchedules() {
func (manager *Manager) evaluateAllSchedules() {
for range manager.evalTicker.C {
log.WithField("total", len(manager.schedules)).Debug("starting to evaluate schedules.")
for name, sched := range manager.schedules {
Expand Down
4 changes: 2 additions & 2 deletions schedule/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,9 +72,9 @@ type Schedule struct {
state State
}

// ScheduleManager is tasked with running and maintaing all the schedules. There should only be 1 per process.
// Manager is tasked with running and maintaing all the schedules. There should only be 1 per process.
// It's tasked with the creation, destruction and evaulation of all schedules.
type ScheduleManager struct {
type Manager struct {
subscriptionTable map[string][]*Schedule
schedules map[string]*Schedule
db dao.ScheduleDAO
Expand Down
2 changes: 1 addition & 1 deletion server/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import (
"github.com/att/deadline/schedule"
)

var manager *schedule.ScheduleManager
var manager *schedule.Manager
var log *logrus.Logger

// DeadlineServer is the http server for the deadline application.
Expand Down

0 comments on commit 8491d00

Please sign in to comment.