From 302093035edefe8011ab736c86a53d5777983e7e Mon Sep 17 00:00:00 2001 From: Maxton Huff Date: Wed, 10 Feb 2021 12:37:13 -0600 Subject: [PATCH] add licence header --- server/trial.go | 33 ++++++++++++++++++++++++++------- 1 file changed, 26 insertions(+), 7 deletions(-) diff --git a/server/trial.go b/server/trial.go index 85df72422..8feb6bfa4 100644 --- a/server/trial.go +++ b/server/trial.go @@ -1,3 +1,22 @@ +// Copyright 2017 Pilosa Corp. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Package server contains the `pilosa server` subcommand which runs Pilosa +// itself. The purpose of this package is to define an easily tested Command +// object which handles interpreting configuration and setting up all the +// objects that Pilosa needs. + package server import ( @@ -12,18 +31,18 @@ func (m *Command) trialVersion() { if pilosa.TrialDeadline != "" { endTime, err := time.Parse("2006-01-02", pilosa.TrialDeadline) if err != nil { - m.logger.Printf("parsing curTime from make file: %v", err) + m.logger.Printf("parsing trial deadline: %v", err) os.Exit(1) } go m.dailyCheck(endTime) } } -const hoursPerCheck = 24 * time.Hour +const trialCheckInterval = 24 * time.Hour // dailyCheck runs in the background while a trial version of Molecula is being run, displaying daily reminders of the remaining days func (m *Command) dailyCheck(endTime time.Time) { - ticker := time.NewTicker(hoursPerCheck) + ticker := time.NewTicker(trialCheckInterval) startTime, err := m.ntpServerTime(4) if err != nil { m.logger.Printf("reading ntp server time %v", err) @@ -44,17 +63,17 @@ func (m *Command) dailyCheck(endTime time.Time) { } } -const url = "0.beevik-ntp.pool.ntp.org" -const timeRequestDelay = 100 * time.Millisecond +const ntpurl = "0.beevik-ntp.pool.ntp.org" +const ntpRetryDelay = 100 * time.Millisecond // ntpServerTime attempts to reach ntp servers with delays between each attempt, returning the time value of the first connected server func (m *Command) ntpServerTime(retries int) (time.Time, error) { - t, err := ntp.Time(url) + t, err := ntp.Time(ntpurl) if err != nil && retries <= 0 { return t, err } if err != nil { - time.Sleep(timeRequestDelay) + time.Sleep(ntpRetryDelay) return m.ntpServerTime(retries - 1) } return t, nil