From 2e1f8d29b5fbc97a91b4219458982d234e01bc0a Mon Sep 17 00:00:00 2001 From: Christian Muehlhaeuser Date: Fri, 13 Nov 2020 00:14:59 +0100 Subject: [PATCH] Fix godoc style comments (#356) --- config/config.go | 10 +++---- config/configUtils.go | 2 +- config/verifyInstall.go | 2 +- controllers/admin.go | 2 +- controllers/admin/changePageContent.go | 2 +- controllers/admin/changeStreamKey.go | 2 +- controllers/admin/disconnect.go | 2 +- controllers/admin/hardware.go | 2 +- controllers/admin/index.go | 2 +- controllers/admin/logs.go | 4 +-- controllers/admin/serverConfig.go | 2 +- controllers/admin/status.go | 2 +- controllers/admin/viewers.go | 2 +- controllers/chat.go | 2 +- controllers/config.go | 2 +- controllers/connectedClients.go | 2 +- controllers/embed.go | 4 +-- controllers/emoji.go | 2 +- controllers/index.go | 2 +- controllers/status.go | 2 +- core/chat/chat.go | 8 ++--- core/chat/client.go | 12 ++++---- core/chat/server.go | 12 ++++---- core/chatListener.go | 12 ++++---- core/core.go | 2 +- core/ffmpeg/fileWriterReceiverService.go | 6 ++-- core/ffmpeg/hlsHandler.go | 8 ++--- core/ffmpeg/thumbnailGenerator.go | 2 +- core/ffmpeg/transcoder.go | 38 ++++++++++++------------ core/playlist/writer.go | 2 +- core/rtmp/rtmp.go | 2 +- core/stats.go | 6 ++-- core/status.go | 4 +-- core/storageproviders/local.go | 10 +++---- core/storageproviders/s3Storage.go | 12 ++++---- core/streamState.go | 8 ++--- geoip/geoip.go | 2 +- logging/logging.go | 6 ++-- main.go | 10 +++---- metrics/metrics.go | 8 ++--- metrics/viewers.go | 2 +- models/broadcaster.go | 2 +- models/chatListener.go | 2 +- models/chatMessage.go | 4 +-- models/emoji.go | 2 +- models/nameChangeEvent.go | 2 +- models/pingMessage.go | 2 +- models/playlist.go | 6 ++-- models/stats.go | 2 +- models/status.go | 2 +- models/storageProvider.go | 2 +- router/middleware/caching.go | 6 ++-- router/middleware/cors.go | 2 +- router/router.go | 2 +- utils/clientId.go | 4 +-- utils/performanceTimer.go | 8 ++--- utils/utils.go | 14 ++++----- yp/api.go | 2 +- yp/yp.go | 6 ++-- 59 files changed, 147 insertions(+), 147 deletions(-) diff --git a/config/config.go b/config/config.go index 7b866a4a9..f9d30d119 100644 --- a/config/config.go +++ b/config/config.go @@ -11,7 +11,7 @@ import ( "gopkg.in/yaml.v2" ) -//Config contains a reference to the configuration +// Config contains a reference to the configuration. var Config *config var _default config @@ -91,7 +91,7 @@ type files struct { MaxNumberInPlaylist int `yaml:"maxNumberInPlaylist"` } -//S3 is for configuring the S3 integration +// S3 is for configuring the S3 integration. type S3 struct { Enabled bool `yaml:"enabled" json:"enabled"` Endpoint string `yaml:"endpoint" json:"endpoint,omitempty"` @@ -229,7 +229,7 @@ func (c *config) GetVideoStreamQualities() []StreamQuality { return _default.VideoSettings.StreamQualities } -// GetFramerate returns the framerate or default +// GetFramerate returns the framerate or default. func (q *StreamQuality) GetFramerate() int { if q.Framerate > 0 { return q.Framerate @@ -238,7 +238,7 @@ func (q *StreamQuality) GetFramerate() int { return _default.VideoSettings.StreamQualities[0].Framerate } -// GetEncoderPreset returns the preset or default +// GetEncoderPreset returns the preset or default. func (q *StreamQuality) GetEncoderPreset() string { if q.EncoderPreset != "" { return q.EncoderPreset @@ -247,7 +247,7 @@ func (q *StreamQuality) GetEncoderPreset() string { return _default.VideoSettings.StreamQualities[0].EncoderPreset } -//Load tries to load the configuration file +// Load tries to load the configuration file. func Load(filePath string, versionInfo string, versionNumber string) error { Config = new(config) _default = getDefaults() diff --git a/config/configUtils.go b/config/configUtils.go index 5b9fa60ae..636e31cb9 100644 --- a/config/configUtils.go +++ b/config/configUtils.go @@ -36,7 +36,7 @@ func findHighestQuality(qualities []StreamQuality) int { return indexedQualities[0].index } -// MarshalJSON is a custom JSON marshal function for video stream qualities +// MarshalJSON is a custom JSON marshal function for video stream qualities. func (q *StreamQuality) MarshalJSON() ([]byte, error) { type Alias StreamQuality return json.Marshal(&struct { diff --git a/config/verifyInstall.go b/config/verifyInstall.go index 4c045ba92..74d429c00 100644 --- a/config/verifyInstall.go +++ b/config/verifyInstall.go @@ -6,7 +6,7 @@ import ( "os" ) -//verifyFFMpegPath verifies that the path exists, is a file, and is executable +// verifyFFMpegPath verifies that the path exists, is a file, and is executable. func verifyFFMpegPath(path string) error { stat, err := os.Stat(path) diff --git a/controllers/admin.go b/controllers/admin.go index 5f9067dbc..47a400bc0 100644 --- a/controllers/admin.go +++ b/controllers/admin.go @@ -6,7 +6,7 @@ import ( "github.com/owncast/owncast/core/rtmp" ) -// DisconnectInboundConnection will force-disconnect an inbound stream +// DisconnectInboundConnection will force-disconnect an inbound stream. func DisconnectInboundConnection(w http.ResponseWriter, r *http.Request) { rtmp.Disconnect() w.WriteHeader(http.StatusOK) diff --git a/controllers/admin/changePageContent.go b/controllers/admin/changePageContent.go index f99634aee..0f98d8773 100644 --- a/controllers/admin/changePageContent.go +++ b/controllers/admin/changePageContent.go @@ -10,7 +10,7 @@ import ( log "github.com/sirupsen/logrus" ) -// ChangeExtraPageContent will change the optional page content +// ChangeExtraPageContent will change the optional page content. func ChangeExtraPageContent(w http.ResponseWriter, r *http.Request) { if r.Method != "POST" { controllers.WriteSimpleResponse(w, false, r.Method+" not supported") diff --git a/controllers/admin/changeStreamKey.go b/controllers/admin/changeStreamKey.go index 9af9da6ae..06ed67c9f 100644 --- a/controllers/admin/changeStreamKey.go +++ b/controllers/admin/changeStreamKey.go @@ -10,7 +10,7 @@ import ( log "github.com/sirupsen/logrus" ) -// ChangeStreamKey will change the stream key (in memory) +// ChangeStreamKey will change the stream key (in memory). func ChangeStreamKey(w http.ResponseWriter, r *http.Request) { if r.Method != "POST" { controllers.WriteSimpleResponse(w, false, r.Method+" not supported") diff --git a/controllers/admin/disconnect.go b/controllers/admin/disconnect.go index 7b1e162a3..d8bf93346 100644 --- a/controllers/admin/disconnect.go +++ b/controllers/admin/disconnect.go @@ -9,7 +9,7 @@ import ( "github.com/owncast/owncast/core/rtmp" ) -// DisconnectInboundConnection will force-disconnect an inbound stream +// DisconnectInboundConnection will force-disconnect an inbound stream. func DisconnectInboundConnection(w http.ResponseWriter, r *http.Request) { if !core.GetStatus().Online { controllers.WriteSimpleResponse(w, false, "no inbound stream connected") diff --git a/controllers/admin/hardware.go b/controllers/admin/hardware.go index 1666acb83..4eb40cf4f 100644 --- a/controllers/admin/hardware.go +++ b/controllers/admin/hardware.go @@ -7,7 +7,7 @@ import ( "github.com/owncast/owncast/metrics" ) -// GetHardwareStats will return hardware utilization over time +// GetHardwareStats will return hardware utilization over time. func GetHardwareStats(w http.ResponseWriter, r *http.Request) { m := metrics.Metrics diff --git a/controllers/admin/index.go b/controllers/admin/index.go index 603d9ebd1..d1ba623d5 100644 --- a/controllers/admin/index.go +++ b/controllers/admin/index.go @@ -11,7 +11,7 @@ import ( log "github.com/sirupsen/logrus" ) -// ServeAdmin will return admin web assets +// ServeAdmin will return admin web assets. func ServeAdmin(w http.ResponseWriter, r *http.Request) { // Set a cache control max-age header middleware.SetCachingHeaders(w, r) diff --git a/controllers/admin/logs.go b/controllers/admin/logs.go index b6e9689ec..5211c3af1 100644 --- a/controllers/admin/logs.go +++ b/controllers/admin/logs.go @@ -9,7 +9,7 @@ import ( "github.com/sirupsen/logrus" ) -// GetLogs will return all logs +// GetLogs will return all logs. func GetLogs(w http.ResponseWriter, r *http.Request) { logs := logging.Logger.AllEntries() response := make([]logsResponse, 0) @@ -22,7 +22,7 @@ func GetLogs(w http.ResponseWriter, r *http.Request) { json.NewEncoder(w).Encode(response) } -// GetWarnings will return only warning and error logs +// GetWarnings will return only warning and error logs. func GetWarnings(w http.ResponseWriter, r *http.Request) { logs := logging.Logger.WarningEntries() response := make([]logsResponse, 0) diff --git a/controllers/admin/serverConfig.go b/controllers/admin/serverConfig.go index abb2b1c12..fa660f584 100644 --- a/controllers/admin/serverConfig.go +++ b/controllers/admin/serverConfig.go @@ -7,7 +7,7 @@ import ( "github.com/owncast/owncast/config" ) -// GetServerConfig gets the config details of the server +// GetServerConfig gets the config details of the server. func GetServerConfig(w http.ResponseWriter, r *http.Request) { var videoQualityVariants = make([]config.StreamQuality, 0) for _, variant := range config.Config.GetVideoStreamQualities() { diff --git a/controllers/admin/status.go b/controllers/admin/status.go index 50bcba868..8f2c3b648 100644 --- a/controllers/admin/status.go +++ b/controllers/admin/status.go @@ -9,7 +9,7 @@ import ( "github.com/owncast/owncast/models" ) -// Status gets the details of the inbound broadcaster +// Status gets the details of the inbound broadcaster. func Status(w http.ResponseWriter, r *http.Request) { broadcaster := core.GetBroadcaster() status := core.GetStatus() diff --git a/controllers/admin/viewers.go b/controllers/admin/viewers.go index 77fa0ad67..8d0d1abb2 100644 --- a/controllers/admin/viewers.go +++ b/controllers/admin/viewers.go @@ -7,7 +7,7 @@ import ( "github.com/owncast/owncast/metrics" ) -// GetViewersOverTime will return the number of viewers at points in time +// GetViewersOverTime will return the number of viewers at points in time. func GetViewersOverTime(w http.ResponseWriter, r *http.Request) { viewersOverTime := metrics.Metrics.Viewers w.Header().Set("Content-Type", "application/json") diff --git a/controllers/chat.go b/controllers/chat.go index f581bd338..01cb0f87f 100644 --- a/controllers/chat.go +++ b/controllers/chat.go @@ -9,7 +9,7 @@ import ( "github.com/owncast/owncast/router/middleware" ) -//GetChatMessages gets all of the chat messages +// GetChatMessages gets all of the chat messages. func GetChatMessages(w http.ResponseWriter, r *http.Request) { middleware.EnableCors(&w) diff --git a/controllers/config.go b/controllers/config.go index 114f253bf..84bf90d4d 100644 --- a/controllers/config.go +++ b/controllers/config.go @@ -8,7 +8,7 @@ import ( "github.com/owncast/owncast/router/middleware" ) -//GetWebConfig gets the status of the server +// GetWebConfig gets the status of the server. func GetWebConfig(w http.ResponseWriter, r *http.Request) { middleware.EnableCors(&w) diff --git a/controllers/connectedClients.go b/controllers/connectedClients.go index 3e3192a7a..13c159150 100644 --- a/controllers/connectedClients.go +++ b/controllers/connectedClients.go @@ -7,7 +7,7 @@ import ( "github.com/owncast/owncast/core" ) -// GetConnectedClients returns currently connected clients +// GetConnectedClients returns currently connected clients. func GetConnectedClients(w http.ResponseWriter, r *http.Request) { clients := core.GetClients() w.Header().Set("Content-Type", "application/json") diff --git a/controllers/embed.go b/controllers/embed.go index 44b38fb85..935b72c90 100644 --- a/controllers/embed.go +++ b/controllers/embed.go @@ -4,12 +4,12 @@ import ( "net/http" ) -//GetChatEmbed gets the embed for chat +// GetChatEmbed gets the embed for chat. func GetChatEmbed(w http.ResponseWriter, r *http.Request) { http.Redirect(w, r, "/index-standalone-chat.html", http.StatusMovedPermanently) } -//GetVideoEmbed gets the embed for video +// GetVideoEmbed gets the embed for video. func GetVideoEmbed(w http.ResponseWriter, r *http.Request) { http.Redirect(w, r, "/index-video-only.html", http.StatusMovedPermanently) } diff --git a/controllers/emoji.go b/controllers/emoji.go index b7b1ffac2..dd7c8f2b4 100644 --- a/controllers/emoji.go +++ b/controllers/emoji.go @@ -17,7 +17,7 @@ import ( // to need it to be. The config is getting a bit bloated. const emojiDir = "/img/emoji" // Relative to webroot -//GetCustomEmoji returns a list of custom emoji via the API +// GetCustomEmoji returns a list of custom emoji via the API. func GetCustomEmoji(w http.ResponseWriter, r *http.Request) { emojiList := make([]models.CustomEmoji, 0) diff --git a/controllers/index.go b/controllers/index.go index 8ea9eb43a..ff33204d9 100644 --- a/controllers/index.go +++ b/controllers/index.go @@ -25,7 +25,7 @@ type MetadataPage struct { TagsString string } -//IndexHandler handles the default index route +// IndexHandler handles the default index route. func IndexHandler(w http.ResponseWriter, r *http.Request) { middleware.EnableCors(&w) isIndexRequest := r.URL.Path == "/" || filepath.Base(r.URL.Path) == "index.html" || filepath.Base(r.URL.Path) == "" diff --git a/controllers/status.go b/controllers/status.go index 14aa88624..5e8841aeb 100644 --- a/controllers/status.go +++ b/controllers/status.go @@ -8,7 +8,7 @@ import ( "github.com/owncast/owncast/router/middleware" ) -//GetStatus gets the status of the server +// GetStatus gets the status of the server. func GetStatus(w http.ResponseWriter, r *http.Request) { middleware.EnableCors(&w) diff --git a/core/chat/chat.go b/core/chat/chat.go index 873216e5a..88879606a 100644 --- a/core/chat/chat.go +++ b/core/chat/chat.go @@ -7,7 +7,7 @@ import ( "github.com/owncast/owncast/models" ) -//Setup sets up the chat server +// Setup sets up the chat server. func Setup(listener models.ChatListener) { setupPersistence() @@ -32,7 +32,7 @@ func Setup(listener models.ChatListener) { } } -//Start starts the chat server +// Start starts the chat server. func Start() error { if _server == nil { return errors.New("chat server is nil") @@ -53,7 +53,7 @@ func Start() error { return errors.New("chat server failed to start") } -//SendMessage sends a message to all +// SendMessage sends a message to all. func SendMessage(message models.ChatMessage) { if _server == nil { return @@ -62,7 +62,7 @@ func SendMessage(message models.ChatMessage) { _server.SendToAll(message) } -//GetMessages gets all of the messages +// GetMessages gets all of the messages. func GetMessages() []models.ChatMessage { if _server == nil { return []models.ChatMessage{} diff --git a/core/chat/client.go b/core/chat/client.go index 361d788e7..773753253 100644 --- a/core/chat/client.go +++ b/core/chat/client.go @@ -44,7 +44,7 @@ const ( PONG = "PONG" ) -//NewClient creates a new chat client +// NewClient creates a new chat client. func NewClient(ws *websocket.Conn) *Client { if ws == nil { log.Panicln("ws cannot be nil") @@ -63,7 +63,7 @@ func NewClient(ws *websocket.Conn) *Client { return &Client{time.Now(), 0, userAgent, ipAddress, nil, clientID, nil, socketID, ws, ch, pingch, usernameChangeChannel, doneCh} } -//GetConnection gets the connection for the client +// GetConnection gets the connection for the client. func (c *Client) GetConnection() *websocket.Conn { return c.ws } @@ -77,18 +77,18 @@ func (c *Client) Write(msg models.ChatMessage) { } } -//Done marks the client as done +// Done marks the client as done. func (c *Client) Done() { c.doneCh <- true } -// Listen Write and Read request via chanel +// Listen Write and Read request via channel. func (c *Client) Listen() { go c.listenWrite() c.listenRead() } -// Listen write request via chanel +// Listen write request via channel. func (c *Client) listenWrite() { for { select { @@ -110,7 +110,7 @@ func (c *Client) listenWrite() { } } -// Listen read request via chanel +// Listen read request via channel. func (c *Client) listenRead() { for { select { diff --git a/core/chat/server.go b/core/chat/server.go index d445726ca..144708942 100644 --- a/core/chat/server.go +++ b/core/chat/server.go @@ -16,7 +16,7 @@ var ( _server *server ) -//Server represents the server which handles the chat +// Server represents the server which handles the chat. type server struct { Clients map[string]*Client @@ -31,27 +31,27 @@ type server struct { errCh chan error } -//Add adds a client to the server +// Add adds a client to the server. func (s *server) add(c *Client) { s.addCh <- c } -//Remove removes a client from the server +// Remove removes a client from the server. func (s *server) remove(c *Client) { s.delCh <- c } -//SendToAll sends a message to all of the connected clients +// SendToAll sends a message to all of the connected clients. func (s *server) SendToAll(msg models.ChatMessage) { s.sendAllCh <- msg } -//Done marks the server as done +// Done marks the server as done. func (s *server) done() { s.doneCh <- true } -//Err handles an error +// Err handles an error. func (s *server) err(err error) { s.errCh <- err } diff --git a/core/chatListener.go b/core/chatListener.go index 52b81701f..684658283 100644 --- a/core/chatListener.go +++ b/core/chatListener.go @@ -7,24 +7,24 @@ import ( "github.com/owncast/owncast/models" ) -//ChatListenerImpl the implementation of the chat client +// ChatListenerImpl the implementation of the chat client. type ChatListenerImpl struct{} -//ClientAdded is for when a client is added the system +// ClientAdded is for when a client is added the system. func (cl ChatListenerImpl) ClientAdded(client models.Client) { SetClientActive(client) } -//ClientRemoved is for when a client disconnects/is removed +// ClientRemoved is for when a client disconnects/is removed. func (cl ChatListenerImpl) ClientRemoved(clientID string) { RemoveClient(clientID) } -//MessageSent is for when a message is sent +// MessageSent is for when a message is sent. func (cl ChatListenerImpl) MessageSent(message models.ChatMessage) { } -//SendMessageToChat sends a message to the chat server +// SendMessageToChat sends a message to the chat server. func SendMessageToChat(message models.ChatMessage) error { if !message.Valid() { return errors.New("invalid chat message; id, author, and body are required") @@ -35,7 +35,7 @@ func SendMessageToChat(message models.ChatMessage) error { return nil } -//GetAllChatMessages gets all of the chat messages +// GetAllChatMessages gets all of the chat messages. func GetAllChatMessages() []models.ChatMessage { return chat.GetMessages() } diff --git a/core/core.go b/core/core.go index d81b5be45..5bdbafd14 100644 --- a/core/core.go +++ b/core/core.go @@ -28,7 +28,7 @@ var ( var handler ffmpeg.HLSHandler var fileWriter = ffmpeg.FileWriterReceiverService{} -//Start starts up the core processing +// Start starts up the core processing. func Start() error { resetDirectories() diff --git a/core/ffmpeg/fileWriterReceiverService.go b/core/ffmpeg/fileWriterReceiverService.go index 73c92bcfa..7dd189648 100644 --- a/core/ffmpeg/fileWriterReceiverService.go +++ b/core/ffmpeg/fileWriterReceiverService.go @@ -15,19 +15,19 @@ import ( log "github.com/sirupsen/logrus" ) -// FileWriterReceiverServiceCallback are to be fired when transcoder responses are written to disk +// FileWriterReceiverServiceCallback are to be fired when transcoder responses are written to disk. type FileWriterReceiverServiceCallback interface { SegmentWritten(localFilePath string) VariantPlaylistWritten(localFilePath string) MasterPlaylistWritten(localFilePath string) } -// FileWriterReceiverService accepts transcoder responses via HTTP and fires the callbacks +// FileWriterReceiverService accepts transcoder responses via HTTP and fires the callbacks. type FileWriterReceiverService struct { callbacks FileWriterReceiverServiceCallback } -// SetupFileWriterReceiverService will start listening for transcoder responses +// SetupFileWriterReceiverService will start listening for transcoder responses. func (s *FileWriterReceiverService) SetupFileWriterReceiverService(callbacks FileWriterReceiverServiceCallback) { s.callbacks = callbacks diff --git a/core/ffmpeg/hlsHandler.go b/core/ffmpeg/hlsHandler.go index 65aa7a42d..bf726bde5 100644 --- a/core/ffmpeg/hlsHandler.go +++ b/core/ffmpeg/hlsHandler.go @@ -4,22 +4,22 @@ import ( "github.com/owncast/owncast/models" ) -// HLSHandler gets told about available HLS playlists and segments +// HLSHandler gets told about available HLS playlists and segments. type HLSHandler struct { Storage models.StorageProvider } -// SegmentWritten is fired when a HLS segment is written to disk +// SegmentWritten is fired when a HLS segment is written to disk. func (h *HLSHandler) SegmentWritten(localFilePath string) { h.Storage.SegmentWritten(localFilePath) } -// VariantPlaylistWritten is fired when a HLS variant playlist is written to disk +// VariantPlaylistWritten is fired when a HLS variant playlist is written to disk. func (h *HLSHandler) VariantPlaylistWritten(localFilePath string) { h.Storage.VariantPlaylistWritten(localFilePath) } -// MasterPlaylistWritten is fired when a HLS master playlist is written to disk +// MasterPlaylistWritten is fired when a HLS master playlist is written to disk. func (h *HLSHandler) MasterPlaylistWritten(localFilePath string) { h.Storage.MasterPlaylistWritten(localFilePath) } diff --git a/core/ffmpeg/thumbnailGenerator.go b/core/ffmpeg/thumbnailGenerator.go index aa58b74e1..44a576750 100644 --- a/core/ffmpeg/thumbnailGenerator.go +++ b/core/ffmpeg/thumbnailGenerator.go @@ -21,7 +21,7 @@ func StopThumbnailGenerator() { } } -//StartThumbnailGenerator starts generating thumbnails +// StartThumbnailGenerator starts generating thumbnails. func StartThumbnailGenerator(chunkPath string, variantIndex int) { // Every 20 seconds create a thumbnail from the most // recent video segment. diff --git a/core/ffmpeg/transcoder.go b/core/ffmpeg/transcoder.go index c9783a391..bd12edff3 100644 --- a/core/ffmpeg/transcoder.go +++ b/core/ffmpeg/transcoder.go @@ -15,7 +15,7 @@ import ( var _commandExec *exec.Cmd -// Transcoder is a single instance of a video transcoder +// Transcoder is a single instance of a video transcoder. type Transcoder struct { input string segmentOutputPath string @@ -30,7 +30,7 @@ type Transcoder struct { TranscoderCompleted func(error) } -// HLSVariant is a combination of settings that results in a single HLS stream +// HLSVariant is a combination of settings that results in a single HLS stream. type HLSVariant struct { index int @@ -45,13 +45,13 @@ type HLSVariant struct { encoderPreset string // A collection of automatic settings for the encoder. https://trac.ffmpeg.org/wiki/Encode/H.264#crf } -// VideoSize is the scaled size of the video output +// VideoSize is the scaled size of the video output. type VideoSize struct { Width int Height int } -// getString returns a WxH formatted getString for scaling video output +// getString returns a WxH formatted getString for scaling video output. func (v *VideoSize) getString() string { widthString := strconv.Itoa(v.Width) heightString := strconv.Itoa(v.Height) @@ -197,7 +197,7 @@ func getVariantFromConfigQuality(quality config.StreamQuality, index int) HLSVar return variant } -// NewTranscoder will return a new Transcoder, populated by the config +// NewTranscoder will return a new Transcoder, populated by the config. func NewTranscoder() *Transcoder { transcoder := new(Transcoder) transcoder.ffmpegPath = config.Config.GetFFMpegPath() @@ -248,7 +248,7 @@ func (v *HLSVariant) getVariantString(t *Transcoder) string { return strings.Join(variantEncoderCommands, " ") } -// Get the command flags for the variants +// Get the command flags for the variants. func (t *Transcoder) getVariantsString() string { var variantsCommandFlags = "" var variantsStreamMaps = " -var_stream_map \"" @@ -267,12 +267,12 @@ func (t *Transcoder) getVariantsString() string { // If we'd like to keep the aspect ratio, we need to specify only one component, either width or height. // Some codecs require the size of width and height to be a multiple of n. You can achieve this by setting the width or height to -n. -// SetVideoScalingWidth will set the scaled video width of this variant +// SetVideoScalingWidth will set the scaled video width of this variant. func (v *HLSVariant) SetVideoScalingWidth(width int) { v.videoSize.Width = width } -// SetVideoScalingHeight will set the scaled video height of this variant +// SetVideoScalingHeight will set the scaled video height of this variant. func (v *HLSVariant) SetVideoScalingHeight(height int) { v.videoSize.Height = height } @@ -284,7 +284,7 @@ func (v *HLSVariant) getScalingString() string { // Video Quality -// SetVideoBitrate will set the output bitrate of this variant's video +// SetVideoBitrate will set the output bitrate of this variant's video. func (v *HLSVariant) SetVideoBitrate(bitrate int) { v.videoBitrate = bitrate } @@ -321,19 +321,19 @@ func (v *HLSVariant) getVideoQualityString(t *Transcoder) string { return strings.Join(cmd, " ") } -// SetVideoFramerate will set the output framerate of this variant's video +// SetVideoFramerate will set the output framerate of this variant's video. func (v *HLSVariant) SetVideoFramerate(framerate int) { v.framerate = framerate } -// SetEncoderPreset will set the video encoder preset of this variant +// SetEncoderPreset will set the video encoder preset of this variant. func (v *HLSVariant) SetEncoderPreset(preset string) { v.encoderPreset = preset } // Audio Quality -// SetAudioBitrate will set the output framerate of this variant's audio +// SetAudioBitrate will set the output framerate of this variant's audio. func (v *HLSVariant) SetAudioBitrate(bitrate string) { v.audioBitrate = bitrate } @@ -348,38 +348,38 @@ func (v *HLSVariant) getAudioQualityString() string { return fmt.Sprintf("-map a:0 -c:a:%d %s -b:a:%d %s", v.index, encoderCodec, v.index, v.audioBitrate) } -// AddVariant adds a new HLS variant to include in the output +// AddVariant adds a new HLS variant to include in the output. func (t *Transcoder) AddVariant(variant HLSVariant) { variant.index = len(t.variants) t.variants = append(t.variants, variant) } -// SetInput sets the input stream on the filesystem +// SetInput sets the input stream on the filesystem. func (t *Transcoder) SetInput(input string) { t.input = input } -// SetOutputPath sets the root directory that should include playlists and video segments +// SetOutputPath sets the root directory that should include playlists and video segments. func (t *Transcoder) SetOutputPath(output string) { t.segmentOutputPath = output } -// SetHLSPlaylistLength will set the max number of items in a HLS variant's playlist +// SetHLSPlaylistLength will set the max number of items in a HLS variant's playlist. func (t *Transcoder) SetHLSPlaylistLength(length int) { t.hlsPlaylistLength = length } -// SetSegmentLength Specifies the number of seconds each segment should be +// SetSegmentLength Specifies the number of seconds each segment should be. func (t *Transcoder) SetSegmentLength(seconds int) { t.segmentLengthSeconds = seconds } -// SetAppendToStream enables appending to the HLS stream instead of overwriting +// SetAppendToStream enables appending to the HLS stream instead of overwriting. func (t *Transcoder) SetAppendToStream(append bool) { t.appendToStream = append } -// SetIdentifer enables appending a unique identifier to segment file name +// SetIdentifer enables appending a unique identifier to segment file name. func (t *Transcoder) SetIdentifier(output string) { t.segmentIdentifier = output } diff --git a/core/playlist/writer.go b/core/playlist/writer.go index 290254075..a15e71040 100644 --- a/core/playlist/writer.go +++ b/core/playlist/writer.go @@ -2,7 +2,7 @@ package playlist import "os" -//WritePlaylist writes the playlist to disk +// WritePlaylist writes the playlist to disk. func WritePlaylist(data string, filePath string) error { f, err := os.Create(filePath) if err != nil { diff --git a/core/rtmp/rtmp.go b/core/rtmp/rtmp.go index 7107c63d5..22843190e 100644 --- a/core/rtmp/rtmp.go +++ b/core/rtmp/rtmp.go @@ -30,7 +30,7 @@ var _rtmpConnection net.Conn var _setStreamAsConnected func() var _setBroadcaster func(models.Broadcaster) -//Start starts the rtmp service, listening on port 1935 +// Start starts the rtmp service, listening on port 1935. func Start(setStreamAsConnected func(), setBroadcaster func(models.Broadcaster)) { _setStreamAsConnected = setStreamAsConnected _setBroadcaster = setBroadcaster diff --git a/core/stats.go b/core/stats.go index 2d180db62..0c55b62da 100644 --- a/core/stats.go +++ b/core/stats.go @@ -46,7 +46,7 @@ func setupStats() error { return nil } -//IsStreamConnected checks if the stream is connected or not +// IsStreamConnected checks if the stream is connected or not. func IsStreamConnected() bool { if !_stats.StreamConnected { return false @@ -62,7 +62,7 @@ func IsStreamConnected() bool { return _stats.StreamConnected } -//SetClientActive sets a client as active and connected +// SetClientActive sets a client as active and connected. func SetClientActive(client models.Client) { l.Lock() // If this clientID already exists then update it. @@ -88,7 +88,7 @@ func SetClientActive(client models.Client) { } } -//RemoveClient removes a client from the active clients record +// RemoveClient removes a client from the active clients record. func RemoveClient(clientID string) { log.Trace("Removing the client:", clientID) diff --git a/core/status.go b/core/status.go index 0aa256e3d..99b162c87 100644 --- a/core/status.go +++ b/core/status.go @@ -5,7 +5,7 @@ import ( "github.com/owncast/owncast/models" ) -//GetStatus gets the status of the system +// GetStatus gets the status of the system. func GetStatus() models.Status { if _stats == nil { return models.Status{} @@ -22,7 +22,7 @@ func GetStatus() models.Status { } } -// setBroadcaster will store the current inbound broadcasting details +// setBroadcaster will store the current inbound broadcasting details. func setBroadcaster(broadcaster models.Broadcaster) { _broadcaster = &broadcaster } diff --git a/core/storageproviders/local.go b/core/storageproviders/local.go index 755a91388..8753d7f75 100644 --- a/core/storageproviders/local.go +++ b/core/storageproviders/local.go @@ -17,7 +17,7 @@ type LocalStorage struct { // Cleanup old public HLS content every N min from the webroot. var _onlineCleanupTicker *time.Ticker -// Setup configures this storage provider +// Setup configures this storage provider. func (s *LocalStorage) Setup() error { // NOTE: This cleanup timer will have to be disabled to support recordings in the future // as all HLS segments have to be publicly available on disk to keep a recording of them. @@ -33,12 +33,12 @@ func (s *LocalStorage) Setup() error { return nil } -// SegmentWritten is called when a single segment of video is written +// SegmentWritten is called when a single segment of video is written. func (s *LocalStorage) SegmentWritten(localFilePath string) { s.Save(localFilePath, 0) } -// VariantPlaylistWritten is called when a variant hls playlist is written +// VariantPlaylistWritten is called when a variant hls playlist is written. func (s *LocalStorage) VariantPlaylistWritten(localFilePath string) { _, err := s.Save(localFilePath, 0) if err != nil { @@ -47,12 +47,12 @@ func (s *LocalStorage) VariantPlaylistWritten(localFilePath string) { } } -// MasterPlaylistWritten is called when the master hls playlist is written +// MasterPlaylistWritten is called when the master hls playlist is written. func (s *LocalStorage) MasterPlaylistWritten(localFilePath string) { s.Save(localFilePath, 0) } -// Save will save a local filepath using the storage provider +// Save will save a local filepath using the storage provider. func (s *LocalStorage) Save(filePath string, retryCount int) (string, error) { newPath := "" diff --git a/core/storageproviders/s3Storage.go b/core/storageproviders/s3Storage.go index a392a125d..0a5c78560 100644 --- a/core/storageproviders/s3Storage.go +++ b/core/storageproviders/s3Storage.go @@ -24,7 +24,7 @@ import ( // then keep a reference to it here. var _queuedPlaylistUpdates = make(map[string]string, 0) -//S3Storage is the s3 implementation of the ChunkStorageProvider +// S3Storage is the s3 implementation of the ChunkStorageProvider. type S3Storage struct { sess *session.Session host string @@ -40,7 +40,7 @@ type S3Storage struct { var _uploader *s3manager.Uploader -//Setup sets up the s3 storage for saving the video to s3 +// Setup sets up the s3 storage for saving the video to s3. func (s *S3Storage) Setup() error { log.Trace("Setting up S3 for external storage of video...") @@ -65,7 +65,7 @@ func (s *S3Storage) Setup() error { return nil } -// SegmentWritten is called when a single segment of video is written +// SegmentWritten is called when a single segment of video is written. func (s *S3Storage) SegmentWritten(localFilePath string) { index := utils.GetIndexFromFilePath(localFilePath) performanceMonitorKey := "s3upload-" + index @@ -100,7 +100,7 @@ func (s *S3Storage) SegmentWritten(localFilePath string) { } } -// VariantPlaylistWritten is called when a variant hls playlist is written +// VariantPlaylistWritten is called when a variant hls playlist is written. func (s *S3Storage) VariantPlaylistWritten(localFilePath string) { // We are uploading the variant playlist after uploading the segment // to make sure we're not referring to files in a playlist that don't @@ -115,13 +115,13 @@ func (s *S3Storage) VariantPlaylistWritten(localFilePath string) { } } -// MasterPlaylistWritten is called when the master hls playlist is written +// MasterPlaylistWritten is called when the master hls playlist is written. func (s *S3Storage) MasterPlaylistWritten(localFilePath string) { // Rewrite the playlist to use absolute remote S3 URLs s.rewriteRemotePlaylist(localFilePath) } -// Save saves the file to the s3 bucket +// Save saves the file to the s3 bucket. func (s *S3Storage) Save(filePath string, retryCount int) (string, error) { file, err := os.Open(filePath) if err != nil { diff --git a/core/streamState.go b/core/streamState.go index abd346a1e..5df5dd812 100644 --- a/core/streamState.go +++ b/core/streamState.go @@ -23,7 +23,7 @@ var _offlineCleanupTimer *time.Timer // While a stream takes place cleanup old HLS content every N min. var _onlineCleanupTicker *time.Ticker -//setStreamAsConnected sets the stream as connected +// setStreamAsConnected sets the stream as connected. func setStreamAsConnected() { _stats.StreamConnected = true _stats.LastConnectTime = utils.NullTime{time.Now(), true} @@ -53,7 +53,7 @@ func setStreamAsConnected() { ffmpeg.StartThumbnailGenerator(segmentPath, config.Config.VideoSettings.HighestQualityStreamIndex) } -//SetStreamAsDisconnected sets the stream as disconnected. +// SetStreamAsDisconnected sets the stream as disconnected. func SetStreamAsDisconnected() { _stats.StreamConnected = false _stats.LastDisconnectTime = utils.NullTime{time.Now(), true} @@ -125,7 +125,7 @@ func SetStreamAsDisconnected() { stopOnlineCleanupTimer() } -// StartOfflineCleanupTimer will fire a cleanup after n minutes being disconnected +// StartOfflineCleanupTimer will fire a cleanup after n minutes being disconnected. func StartOfflineCleanupTimer() { _offlineCleanupTimer = time.NewTimer(5 * time.Minute) go func() { @@ -141,7 +141,7 @@ func StartOfflineCleanupTimer() { }() } -// StopOfflineCleanupTimer will stop the previous cleanup timer +// StopOfflineCleanupTimer will stop the previous cleanup timer. func StopOfflineCleanupTimer() { if _offlineCleanupTimer != nil { _offlineCleanupTimer.Stop() diff --git a/geoip/geoip.go b/geoip/geoip.go index b16f46cca..212120225 100644 --- a/geoip/geoip.go +++ b/geoip/geoip.go @@ -15,7 +15,7 @@ import ( var _geoIPCache = map[string]GeoDetails{} var _enabled = true // Try to use GeoIP support it by default. -// GeoDetails stores details about a location +// GeoDetails stores details about a location. type GeoDetails struct { CountryCode string `json:"countryCode"` RegionName string `json:"regionName"` diff --git a/logging/logging.go b/logging/logging.go index 639870ec3..5dfe05abf 100644 --- a/logging/logging.go +++ b/logging/logging.go @@ -20,7 +20,7 @@ type OCLogger struct { var Logger *OCLogger -// Setup configures our custom logging destinations +// Setup configures our custom logging destinations. func Setup() { logger.SetOutput(os.Stdout) // Send all logs to console @@ -30,7 +30,7 @@ func Setup() { Logger = _logger } -// Fire runs for every logging request +// Fire runs for every logging request. func (l *OCLogger) Fire(e *logger.Entry) error { // Store all log messages to return back in the logging API l.mu.Lock() @@ -44,7 +44,7 @@ func (l *OCLogger) Fire(e *logger.Entry) error { return nil } -// Levels specifies what log levels we care about +// Levels specifies what log levels we care about. func (l *OCLogger) Levels() []logrus.Level { return logrus.AllLevels } diff --git a/main.go b/main.go index 929a8ccb5..bcd90faf1 100644 --- a/main.go +++ b/main.go @@ -16,13 +16,13 @@ import ( "github.com/owncast/owncast/router" ) -// the following are injected at build-time +// the following are injected at build-time. var ( - //GitCommit is the commit which this version of owncast is running + // GitCommit is the commit which this version of owncast is running. GitCommit = "unknown" - //BuildVersion is the version + // BuildVersion is the version. BuildVersion = "0.0.0" - //BuildType is the type of build + // BuildType is the type of build. BuildType = "localdev" ) @@ -77,7 +77,7 @@ func main() { } } -//getReleaseString gets the version string +// getReleaseString gets the version string. func getReleaseString() string { return fmt.Sprintf("Owncast v%s-%s (%s)", BuildVersion, BuildType, GitCommit) } diff --git a/metrics/metrics.go b/metrics/metrics.go index a32345a6d..8909113b4 100644 --- a/metrics/metrics.go +++ b/metrics/metrics.go @@ -4,10 +4,10 @@ import ( "time" ) -// How often we poll for updates +// How often we poll for updates. const metricsPollingInterval = 1 * time.Minute -// CollectedMetrics stores different collected + timestamped values +// CollectedMetrics stores different collected + timestamped values. type CollectedMetrics struct { CPUUtilizations []timestampedValue `json:"cpu"` RAMUtilizations []timestampedValue `json:"memory"` @@ -16,10 +16,10 @@ type CollectedMetrics struct { Viewers []timestampedValue `json:"-"` } -// Metrics is the shared Metrics instance +// Metrics is the shared Metrics instance. var Metrics *CollectedMetrics -// Start will begin the metrics collection and alerting +// Start will begin the metrics collection and alerting. func Start() { Metrics = new(CollectedMetrics) go startViewerCollectionMetrics() diff --git a/metrics/viewers.go b/metrics/viewers.go index 0d03da257..d32521ee1 100644 --- a/metrics/viewers.go +++ b/metrics/viewers.go @@ -6,7 +6,7 @@ import ( "github.com/owncast/owncast/core" ) -// How often we poll for updates +// How often we poll for updates. const viewerMetricsPollingInterval = 5 * time.Minute func startViewerCollectionMetrics() { diff --git a/models/broadcaster.go b/models/broadcaster.go index a32db1bdf..cf2119b46 100644 --- a/models/broadcaster.go +++ b/models/broadcaster.go @@ -20,7 +20,7 @@ type InboundStreamDetails struct { Encoder string `json:"encoder"` } -// RTMPStreamMetadata is the raw metadata that comes in with a RTMP connection +// RTMPStreamMetadata is the raw metadata that comes in with a RTMP connection. type RTMPStreamMetadata struct { Width int `json:"width"` Height int `json:"height"` diff --git a/models/chatListener.go b/models/chatListener.go index 8dc18de36..bf1ffcf7c 100644 --- a/models/chatListener.go +++ b/models/chatListener.go @@ -1,6 +1,6 @@ package models -//ChatListener represents the listener for the chat server +// ChatListener represents the listener for the chat server. type ChatListener interface { ClientAdded(client Client) ClientRemoved(clientID string) diff --git a/models/chatMessage.go b/models/chatMessage.go index af65b385d..e0bf03065 100644 --- a/models/chatMessage.go +++ b/models/chatMessage.go @@ -12,7 +12,7 @@ import ( "mvdan.cc/xurls" ) -//ChatMessage represents a single chat message +// ChatMessage represents a single chat message. type ChatMessage struct { ClientID string `json:"-"` @@ -24,7 +24,7 @@ type ChatMessage struct { Timestamp time.Time `json:"timestamp"` } -//Valid checks to ensure the message is valid +// Valid checks to ensure the message is valid. func (m ChatMessage) Valid() bool { return m.Author != "" && m.Body != "" && m.ID != "" } diff --git a/models/emoji.go b/models/emoji.go index e63e7725d..f2029f0b3 100644 --- a/models/emoji.go +++ b/models/emoji.go @@ -1,6 +1,6 @@ package models -//CustomEmoji represents an image that can be used in chat as a custom emoji +// CustomEmoji represents an image that can be used in chat as a custom emoji. type CustomEmoji struct { Name string `json:"name"` Emoji string `json:"emoji"` diff --git a/models/nameChangeEvent.go b/models/nameChangeEvent.go index a08cdb8e0..7ce166e79 100644 --- a/models/nameChangeEvent.go +++ b/models/nameChangeEvent.go @@ -1,6 +1,6 @@ package models -//NameChangeEvent represents a user changing their name in chat +// NameChangeEvent represents a user changing their name in chat. type NameChangeEvent struct { OldName string `json:"oldName"` NewName string `json:"newName"` diff --git a/models/pingMessage.go b/models/pingMessage.go index 358115822..4a5f63dc1 100644 --- a/models/pingMessage.go +++ b/models/pingMessage.go @@ -1,6 +1,6 @@ package models -//PingMessage represents a ping message between the client and server +// PingMessage represents a ping message between the client and server. type PingMessage struct { MessageType string `json:"type"` } diff --git a/models/playlist.go b/models/playlist.go index e49c85262..e8839f52d 100644 --- a/models/playlist.go +++ b/models/playlist.go @@ -1,6 +1,6 @@ package models -//Segment represents a segment of the live stream +// Segment represents a segment of the live stream. type Segment struct { VariantIndex int // The bitrate variant FullDiskPath string // Where it lives on disk @@ -8,13 +8,13 @@ type Segment struct { RemoteURL string } -//Variant represents a single video variant and the segments that make it up +// Variant represents a single video variant and the segments that make it up. type Variant struct { VariantIndex int Segments map[string]*Segment } -//GetSegmentForFilename gets the segment for the provided filename +// GetSegmentForFilename gets the segment for the provided filename. func (v *Variant) GetSegmentForFilename(filename string) *Segment { return v.Segments[filename] } diff --git a/models/stats.go b/models/stats.go index 019edbda4..a94458dec 100644 --- a/models/stats.go +++ b/models/stats.go @@ -4,7 +4,7 @@ import ( "github.com/owncast/owncast/utils" ) -//Stats holds the stats for the system +// Stats holds the stats for the system. type Stats struct { SessionMaxViewerCount int `json:"sessionMaxViewerCount"` OverallMaxViewerCount int `json:"overallMaxViewerCount"` diff --git a/models/status.go b/models/status.go index b307cddbb..972fc1269 100644 --- a/models/status.go +++ b/models/status.go @@ -2,7 +2,7 @@ package models import "github.com/owncast/owncast/utils" -//Status represents the status of the system +// Status represents the status of the system. type Status struct { Online bool `json:"online"` ViewerCount int `json:"viewerCount"` diff --git a/models/storageProvider.go b/models/storageProvider.go index 0d4ee39db..ee874b9ba 100644 --- a/models/storageProvider.go +++ b/models/storageProvider.go @@ -1,6 +1,6 @@ package models -//StorageProvider is how a chunk storage provider should be implemented +// StorageProvider is how a chunk storage provider should be implemented. type StorageProvider interface { Setup() error Save(filePath string, retryCount int) (string, error) diff --git a/router/middleware/caching.go b/router/middleware/caching.go index 350197e6f..6f28615f9 100644 --- a/router/middleware/caching.go +++ b/router/middleware/caching.go @@ -10,7 +10,7 @@ import ( "github.com/owncast/owncast/utils" ) -//DisableCache writes the disable cache header on the responses +// DisableCache writes the disable cache header on the responses. func DisableCache(w http.ResponseWriter) { w.Header().Set("Cache-Control", "no-cache, no-store, must-revalidate") w.Header().Set("Expires", "Thu, 1 Jan 1970 00:00:00 GMT") @@ -21,7 +21,7 @@ func setCacheSeconds(seconds int, w http.ResponseWriter) { w.Header().Set("Cache-Control", "public, max-age="+secondsStr) } -// ProcessEtags gets and sets ETags for caching purposes +// ProcessEtags gets and sets ETags for caching purposes. func ProcessEtags(w http.ResponseWriter, r *http.Request) int { info, err := os.Stat(filepath.Join("webroot", r.URL.Path)) if err != nil { @@ -40,7 +40,7 @@ func ProcessEtags(w http.ResponseWriter, r *http.Request) int { return 0 } -// SetCachingHeaders will set the cache control header of a response +// SetCachingHeaders will set the cache control header of a response. func SetCachingHeaders(w http.ResponseWriter, r *http.Request) { setCacheSeconds(utils.GetCacheDurationSecondsForPath(r.URL.Path), w) } diff --git a/router/middleware/cors.go b/router/middleware/cors.go index 50c7f5779..57c4284c0 100644 --- a/router/middleware/cors.go +++ b/router/middleware/cors.go @@ -4,7 +4,7 @@ import ( "net/http" ) -//EnableCors enables the cors header on the responses +// EnableCors enables the cors header on the responses. func EnableCors(w *http.ResponseWriter) { (*w).Header().Set("Access-Control-Allow-Origin", "*") } diff --git a/router/router.go b/router/router.go index ddfa11ed1..a5c148f94 100644 --- a/router/router.go +++ b/router/router.go @@ -14,7 +14,7 @@ import ( "github.com/owncast/owncast/yp" ) -//Start starts the router for the http, ws, and rtmp +// Start starts the router for the http, ws, and rtmp. func Start() error { // static files http.HandleFunc("/", controllers.IndexHandler) diff --git a/utils/clientId.go b/utils/clientId.go index 86ad7e45f..41947536a 100644 --- a/utils/clientId.go +++ b/utils/clientId.go @@ -10,7 +10,7 @@ import ( log "github.com/sirupsen/logrus" ) -//GenerateClientIDFromRequest generates a client id from the provided request +// GenerateClientIDFromRequest generates a client id from the provided request. func GenerateClientIDFromRequest(req *http.Request) string { ipAddress := GetIPAddressFromRequest(req) ipAddressComponents := strings.Split(ipAddress, ":") @@ -23,7 +23,7 @@ func GenerateClientIDFromRequest(req *http.Request) string { return hex.EncodeToString(hasher.Sum(nil)) } -// GetIPAddressFromRequest returns the IP address from a http request +// GetIPAddressFromRequest returns the IP address from a http request. func GetIPAddressFromRequest(req *http.Request) string { ipAddressString := req.RemoteAddr xForwardedFor := req.Header.Get("X-FORWARDED-FOR") diff --git a/utils/performanceTimer.go b/utils/performanceTimer.go index e0abfdae9..2a4655f82 100644 --- a/utils/performanceTimer.go +++ b/utils/performanceTimer.go @@ -5,13 +5,13 @@ import ( "time" ) -// The "start" timestamp of a timing event +// The "start" timestamp of a timing event. var _pointsInTime = make(map[string]time.Time) -// A collection of timestamp durations for returning the average of +// A collection of timestamp durations for returning the average of. var _durationStorage = make(map[string][]float64) -// StartPerformanceMonitor will keep track of the start time of this event +// StartPerformanceMonitor will keep track of the start time of this event. func StartPerformanceMonitor(key string) { if len(_durationStorage[key]) > 30 { _durationStorage[key] = removeHighAndLow(_durationStorage[key]) @@ -19,7 +19,7 @@ func StartPerformanceMonitor(key string) { _pointsInTime[key] = time.Now() } -// GetAveragePerformance will return the average durations for the event +// GetAveragePerformance will return the average durations for the event. func GetAveragePerformance(key string) float64 { timestamp := _pointsInTime[key] if timestamp.IsZero() { diff --git a/utils/utils.go b/utils/utils.go index 935e23f3e..54ba79621 100644 --- a/utils/utils.go +++ b/utils/utils.go @@ -15,12 +15,12 @@ import ( "mvdan.cc/xurls" ) -//GetTemporaryPipePath gets the temporary path for the streampipe.flv file +// GetTemporaryPipePath gets the temporary path for the streampipe.flv file. func GetTemporaryPipePath() string { return filepath.Join(os.TempDir(), "streampipe.flv") } -//DoesFileExists checks if the file exists +// DoesFileExists checks if the file exists. func DoesFileExists(name string) bool { if _, err := os.Stat(name); err != nil { if os.IsNotExist(err) { @@ -31,7 +31,7 @@ func DoesFileExists(name string) bool { return true } -//GetRelativePathFromAbsolutePath gets the relative path from the provided absolute path +// GetRelativePathFromAbsolutePath gets the relative path from the provided absolute path. func GetRelativePathFromAbsolutePath(path string) string { pathComponents := strings.Split(path, "/") variant := pathComponents[len(pathComponents)-2] @@ -47,7 +47,7 @@ func GetIndexFromFilePath(path string) string { return variant } -//Copy copies the file to destination +// Copy copies the file to destination. func Copy(source, destination string) error { input, err := ioutil.ReadFile(source) if err != nil { @@ -57,12 +57,12 @@ func Copy(source, destination string) error { return ioutil.WriteFile(destination, input, 0644) } -//Move moves the file to destination +// Move moves the file to destination. func Move(source, destination string) error { return os.Rename(source, destination) } -// IsUserAgentABot returns if a web client user-agent is seen as a bot +// IsUserAgentABot returns if a web client user-agent is seen as a bot. func IsUserAgentABot(userAgent string) bool { if userAgent == "" { return false @@ -111,7 +111,7 @@ func RenderSimpleMarkdown(raw string) string { return buf.String() } -// GetCacheDurationSecondsForPath will return the number of seconds to cache an item +// GetCacheDurationSecondsForPath will return the number of seconds to cache an item. func GetCacheDurationSecondsForPath(filePath string) int { if path.Base(filePath) == "thumbnail.jpg" { // Thumbnails re-generate during live diff --git a/yp/api.go b/yp/api.go index 5b8382e5e..12a0d160e 100644 --- a/yp/api.go +++ b/yp/api.go @@ -22,7 +22,7 @@ type ypDetailsResponse struct { LastConnectTime utils.NullTime `json:"lastConnectTime"` } -//GetYPResponse gets the status of the server for YP purposes +// GetYPResponse gets the status of the server for YP purposes. func GetYPResponse(w http.ResponseWriter, r *http.Request) { status := getStatus() diff --git a/yp/yp.go b/yp/yp.go index fec8d47d5..59c201371 100644 --- a/yp/yp.go +++ b/yp/yp.go @@ -38,13 +38,13 @@ type ypPingRequest struct { URL string `json:"url"` } -// NewYP creates a new instance of the YP service handler +// NewYP creates a new instance of the YP service handler. func NewYP(getStatusFunc func() models.Status) *YP { getStatus = getStatusFunc return &YP{} } -// Start is run when a live stream begins to start pinging YP +// Start is run when a live stream begins to start pinging YP. func (yp *YP) Start() { yp.timer = time.NewTicker(pingInterval) @@ -60,7 +60,7 @@ func (yp *YP) Start() { yp.ping() } -// Stop stops the pinging of YP +// Stop stops the pinging of YP. func (yp *YP) Stop() { yp.timer.Stop() }