This repository has been archived by the owner on Nov 19, 2022. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 38
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
0cbf9c1
commit c71ba66
Showing
139 changed files
with
903 additions
and
49,063 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Empty file.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
|
||
( ) | ||
( ) | ||
( ) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
package main | ||
|
||
import ( | ||
"fmt" | ||
"os" | ||
"os/signal" | ||
"syscall" | ||
|
||
"github.com/streamhut/streamhut/pkg/db" | ||
"github.com/streamhut/streamhut/pkg/db/sqlite3db" | ||
"github.com/streamhut/streamhut/pkg/httpserver" | ||
"github.com/streamhut/streamhut/pkg/tcpserver" | ||
"github.com/streamhut/streamhut/pkg/wsserver" | ||
) | ||
|
||
func main() { | ||
dbtype := "sqlite3" | ||
var db db.DB | ||
if dbtype == "sqlite3" { | ||
db = sqlite3db.NewDB(&sqlite3db.Config{ | ||
DBPath: "./data/sqlite3.db", | ||
}) | ||
} | ||
ws := wsserver.NewWS(&wsserver.Config{ | ||
DB: db, | ||
}) | ||
tcpServer := tcpserver.NewServer(&tcpserver.Config{ | ||
WS: ws, | ||
Port: 1337, | ||
DB: db, | ||
}) | ||
|
||
go tcpServer.Start() | ||
|
||
server := httpserver.NewServer(&httpserver.Config{ | ||
Port: 8080, | ||
WS: ws, | ||
}) | ||
|
||
var gracefulStop = make(chan os.Signal) | ||
signal.Notify(gracefulStop, syscall.SIGTERM) | ||
signal.Notify(gracefulStop, syscall.SIGINT) | ||
go func() { | ||
sig := <-gracefulStop | ||
fmt.Printf("caught sig: %+v\nshutting down...", sig) | ||
db.Close() | ||
os.Exit(0) | ||
}() | ||
|
||
server.Start() | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
package byteutil | ||
|
||
var arrSize = 100 | ||
|
||
// BufferWithMime ... | ||
func BufferWithMime(buf []byte, mime string) []byte { | ||
m := make([]byte, arrSize) | ||
copy(m, []byte(mime)) | ||
buf = append(m, buf...) | ||
return buf | ||
} | ||
|
||
// DecoupleBufferWithMime ... | ||
func DecoupleBufferWithMime(buf []byte) ([]byte, string) { | ||
mime := buf[:arrSize] | ||
b := buf[arrSize:] | ||
|
||
return b, string(mime) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
package byteutil | ||
|
||
import ( | ||
"fmt" | ||
"testing" | ||
) | ||
|
||
func TestBufferWithMime(t *testing.T) { | ||
b := []byte("hello") | ||
m := "text/plain" | ||
bm := BufferWithMime(b, m) | ||
|
||
fmt.Println(string(bm)) | ||
} | ||
|
||
func TestDecoupleBufferWithMime(t *testing.T) { | ||
b := []byte("hello") | ||
m := "text/plain" | ||
bm := BufferWithMime(b, m) | ||
buf, mime := DecoupleBufferWithMime(bm) | ||
|
||
fmt.Println(string(buf)) | ||
fmt.Println(mime) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
package stringutil | ||
|
||
import ( | ||
"math/rand" | ||
"time" | ||
) | ||
|
||
//var letterRunes = []rune("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ") | ||
var letterRunes = []rune("abcdefghijklmnopqrstuvwxyz") | ||
|
||
// RandStringRunes ... | ||
func RandStringRunes(n int) string { | ||
b := make([]rune, n) | ||
for i := range b { | ||
b[i] = letterRunes[rand.Intn(len(letterRunes))] | ||
} | ||
return string(b) | ||
} | ||
|
||
func init() { | ||
rand.Seed(time.Now().UnixNano()) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
package stringutil | ||
|
||
import ( | ||
"fmt" | ||
"testing" | ||
) | ||
|
||
func TestRandStringRunes(t *testing.T) { | ||
str := RandStringRunes(5) | ||
fmt.Println(str) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
package util | ||
|
||
// ValidChannelName ... | ||
func ValidChannelName(channel string) bool { | ||
return true | ||
} | ||
|
||
// NormalizeChannelName ... | ||
func NormalizeChannelName(channel string) string { | ||
return channel | ||
} |
Binary file not shown.
Binary file not shown.
Binary file not shown.
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.