Refactor ipfs storage behind a standard interface

This commit is contained in:
Gabe Kangas
2020-06-02 23:05:15 -07:00
parent a1e9271d3b
commit 16047d884d
6 changed files with 356 additions and 74 deletions

19
main.go
View File

@@ -5,11 +5,10 @@ import (
"net/http"
"strconv"
icore "github.com/ipfs/interface-go-ipfs-core"
log "github.com/sirupsen/logrus"
)
var ipfs icore.CoreAPI
var storage ChunkStorage
var configuration = getConfig()
var server *Server
@@ -24,9 +23,11 @@ func main() {
log.Println("Starting up. Please wait...")
if configuration.IPFS.Enabled {
storage = &IPFSStorage{}
(storage).Setup(configuration)
hlsDirectoryPath = configuration.PrivateHLSPath
enableIPFS()
go monitorVideoContent(hlsDirectoryPath, configuration, &ipfs)
go monitorVideoContent(hlsDirectoryPath, configuration, storage)
}
go startChatServer()
@@ -34,16 +35,6 @@ func main() {
startRTMPService()
}
func enableIPFS() {
log.Println("Enabling IPFS support...")
ipfsInstance, node, _ := createIPFSInstance()
ipfs = *ipfsInstance
createIPFSDirectory(ipfsInstance, "./hls")
go startIPFSNode(ipfs, node)
}
func startChatServer() {
// log.SetFlags(log.Lshortfile)