Skip to content

Commit

Permalink
PubNub SDK v4.9.1 release.
Browse files Browse the repository at this point in the history
  • Loading branch information
client-engineering-bot committed Oct 1, 2020
1 parent a406940 commit af887fa
Show file tree
Hide file tree
Showing 12 changed files with 146 additions and 18 deletions.
12 changes: 11 additions & 1 deletion .pubnub.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,16 @@
---
version: v4.9.0
version: v4.9.1
changelog:
-
changes:
-
text: "Fix for a deadlock on destroy."
type: bug
-
text: "Fetch response nil check."
type: bug
date: Oct 1, 20
version: v4.9.1
-
changes:
-
Expand Down
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
## [v4.9.1](https://github.com/pubnub/go/releases/tag/v4.9.1)
October-1-2020

#### Fixed
- Fix for a deadlock on destroy.
- Fetch response nil check.

## [v4.9.0](https://github.com/pubnub/go/releases/tag/v4.9.0)
August-11-2020

Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# PubNub 4.9.0 client for Go
# PubNub 4.9.1 client for Go
* Go (1.9+)

# Please direct all Support Questions and Concerns to [email protected]
Expand Down
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
4.9.0
4.9.1
86 changes: 82 additions & 4 deletions examples/cli/cli_demo.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,8 @@ func connect() {
config.Log.SetPrefix("PubNub :-> ")
config.PublishKey = "demo"
config.SubscribeKey = "demo"
config.CipherKey = "enigma"

//config.CipherKey = "enigma"
config.UseRandomInitializationVector = true

pn = pubnub.NewPubNub(config)
Expand Down Expand Up @@ -611,8 +612,16 @@ func readCommand(cmd string) {
getMessageActionsRec(command[1:])
case "getactionsrec2":
getMessageActionsRec(command[1:])
case "remaction":
removeMessageActions(command[1:])
case "uploadfile":
uploadFile(command[1:])
case "delfile":
delFile(command[1:])
case "listfiles":
listFiles(command[1:])
case "getfileurl":
getFileURL(command[1:])
case "downloadfile":
downloadFile(command[1:])
case "q":
pn.UnsubscribeAll()
case "d":
Expand All @@ -623,6 +632,75 @@ func readCommand(cmd string) {
}
}

func uploadFile(args []string) {
channel := args[0]
message := args[1]
name := args[2]
filepath := args[3]
file, err := os.Open(filepath)

defer file.Close()

cipherKey := args[4]
res, status, err := pn.SendFile().Channel(channel).Message(message).CipherKey(cipherKey).Name(name).File(file).Execute()
fmt.Println("status", status)
fmt.Println("err", err)
fmt.Println("res", res)

}

func delFile(args []string) {
ch := args[0]
id := args[1]
name := args[2]

res, status, err := pn.DeleteFile().Channel(ch).ID(id).Name(name).Execute()
fmt.Println("status", status)
fmt.Println("err", err)
fmt.Println("res", res)
}

func listFiles(args []string) {
ch := args[0]
res, status, err := pn.ListFiles().Channel(ch).Execute()
fmt.Println("status", status)
fmt.Println("err", err)
fmt.Println("res", res)
}

func getFileURL(args []string) {
ch := args[0]
id := args[1]
name := args[2]

res, status, err := pn.GetFileURL().Channel(ch).ID(id).Name(name).Execute()
fmt.Println("status", status)
fmt.Println("err", err)
fmt.Println("res", res)
}

func downloadFile(args []string) {
ch := args[0]
id := args[1]
name := args[2]

resDLFile, status, err := pn.DownloadFile().Channel(ch).ID(id).Name(name).Execute()
fmt.Println("status", status)
fmt.Println("err", err)
fmt.Println("res", resDLFile)

if resDLFile != nil {
out, _ := os.Create("out.txt")
defer out.Close()

_, err := io.Copy(out, resDLFile.File)

if err != nil {
fmt.Println(err)
}
}
}

func getMessageActionsRec2(args []string) {
channel := args[0]
getMessageActionsRecursive(channel, "", false, 0)
Expand Down Expand Up @@ -2243,7 +2321,7 @@ func publishRequest(args []string) {

res, status, err := pn.Publish().
Channel(ch).
Message(message).
Message("Text with 😜 emoji 🎉" + message).
UsePost(usePost).
ShouldStore(store).
Meta(meta).
Expand Down
7 changes: 6 additions & 1 deletion fetch_request.go
Original file line number Diff line number Diff line change
Expand Up @@ -351,7 +351,12 @@ func (o *fetchOpts) fetchMessages(channels map[string]interface{}) map[string][]
o.pubnub.Config.Log.Printf("MessageType conversion error.")
}
default:
o.pubnub.Config.Log.Printf("histResponse message_type type %vv", reflect.TypeOf(v).Kind())
o.pubnub.Config.Log.Printf("histResponse message_type type %vv", d)
if v != nil {
o.pubnub.Config.Log.Printf("histResponse message_type type %vv", reflect.TypeOf(v).Kind())
} else {
o.pubnub.Config.Log.Printf("histResponse message_type nil")
}
}
}
if d, ok := histResponse["uuid"]; ok {
Expand Down
6 changes: 3 additions & 3 deletions listener_manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,19 +72,19 @@ func (m *ListenerManager) removeAllListeners() {
m.pubnub.Config.Log.Println("in removeAllListeners")
m.Lock()
lis := m.listeners
m.Unlock()
for l := range lis {
delete(m.listeners, l)
}
m.Unlock()
}

func (m *ListenerManager) copyListeners() map[*Listener]bool {
m.RLock()
m.Lock()
lis := make(map[*Listener]bool)
for k, v := range m.listeners {
lis[k] = v
}
m.RUnlock()
m.Unlock()
return lis
}

Expand Down
3 changes: 2 additions & 1 deletion pubnub.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import (
// Default constants
const (
// Version :the version of the SDK
Version = "4.9.0"
Version = "4.9.1"
// MaxSequence for publish messages
MaxSequence = 65535
)
Expand Down Expand Up @@ -707,6 +707,7 @@ func (pn *PubNub) PublishFileMessageWithContext(ctx Context) *publishFileMessage
// Destroy stops all open requests, removes listeners, closes heartbeats, and cleans up.
func (pn *PubNub) Destroy() {
pn.Config.Log.Println("Calling Destroy")
pn.UnsubscribeAll()
pn.cancel()

if pn.subscriptionManager != nil {
Expand Down
8 changes: 5 additions & 3 deletions scripts/run-tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,11 @@ go test -v -race -coverprofile=helpers_tests.out -covermode=atomic -coverpkg=./
go test -v -race -coverprofile=integration_tests.out \
-covermode=atomic -coverpkg=./ ./tests/e2e/

go test -v -race -run TestDestroy -count 20 -coverprofile=deadlock_tests.out \
go test -v -race -run "TestDestroy\b" -count 20 -coverprofile=deadlock_tests.out \

go test -v -race -run "TestDestroy2\b" -count 20 -coverprofile=deadlock2_tests.out \
-covermode=atomic -coverpkg=./ ./tests/e2e/

gocovmerge functional_tests.out integration_tests.out utils_tests.out helpers_tests.out deadlock_tests.out > coverage.txt
gocovmerge functional_tests.out integration_tests.out utils_tests.out helpers_tests.out deadlock_tests.out deadlock2_tests.out > coverage.txt

rm integration_tests.out functional_tests.out utils_tests.out helpers_tests.out deadlock_tests.out
rm integration_tests.out functional_tests.out utils_tests.out helpers_tests.out deadlock_tests.out deadlock2_tests.out
Binary file modified tests/e2e/file_upload_test_output.txt
Binary file not shown.
5 changes: 2 additions & 3 deletions tests/e2e/files_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,6 @@ func FileUploadCommon(t *testing.T, useCipher bool, customCipher string, filepat
if enableDebuggingInTests {
pn.Config.Log = log.New(os.Stdout, "", log.Ldate|log.Ltime|log.Lshortfile)
}

cipherKey := ""
if useCipher {
if customCipher != "" {
Expand Down Expand Up @@ -287,8 +286,8 @@ func FileUploadCommon(t *testing.T, useCipher bool, customCipher string, filepat
assert.Nil(errDelFile)
assert.Equal(200, statusDelFile.StatusCode)

_, statusGetFile2, _ := pn.DownloadFile().Channel(ch).ID(id).Name(name).Execute()
assert.Equal(404, statusGetFile2.StatusCode)
// _, statusGetFile2, _ := pn.DownloadFile().Channel(ch).ID(id).Name(name).Execute()
// assert.Equal(404, statusGetFile2.StatusCode)

} else {
assert.Fail("resSendFile nil")
Expand Down
26 changes: 26 additions & 0 deletions tests/e2e/pn_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
"os"
"runtime"
"testing"

//"time"

pubnub "github.com/pubnub/go"
Expand Down Expand Up @@ -60,3 +61,28 @@ func TestDestroy(t *testing.T) {

pn = nil
}

func TestDestroy2(t *testing.T) {
testSerial := "bb"
config := configCopy()
// go func() {
// log.Println(http.ListenAndServe("localhost:6060", nil))
// }()

if enableDebuggingInTests {
config.Log = log.New(os.Stdout, "", log.Ltime|log.Lmicroseconds)
}
config.PNReconnectionPolicy = pubnub.PNExponentialPolicy
config.MaximumReconnectionRetries = -1
config.UUID = testSerial
config.SuppressLeaveEvents = true
config.SetPresenceTimeoutWithCustomInterval(330, 300)
config.MaxWorkers = 0

pn := pubnub.NewPubNub(config)
listener := pubnub.NewListener()
pn.AddListener(listener)
pn.Subscribe().Channels([]string{"a." + testSerial}).Execute()
<-listener.Status
pn.Destroy()
}

0 comments on commit af887fa

Please sign in to comment.