Skip to content

Add support for mysql instead of Bbolt and URL prefix strip#82

Merged
Finb merged 5 commits intoFinb:masterfrom
athurg:support_mysql
Sep 22, 2021
Merged

Add support for mysql instead of Bbolt and URL prefix strip#82
Finb merged 5 commits intoFinb:masterfrom
athurg:support_mysql

Conversation

@athurg
Copy link
Copy Markdown

@athurg athurg commented Sep 18, 2021

Support MySQL instead of Bbolt

Add support for mysql instead of Bbolt.

So we can run it without local file system requirement.

It's convenient to use in the container environment , especially in clusters like kubernetes.

Support URL Path Prefix strip

While most of LoadBalancer does not support strip URL path prefix. This URL path prefix was used when multiple application shared a load balancer.

For example, bark-server and gmail share a LB bind with api.google.com. They can both access by http://api.google.com/bark-server/ping and http://api.google.com/gmail/ping. When the LB forward the request to bark-server, it will send a request PATH /bark-server/ping , not a really PATH /ping with the prefix /bark-server stripped.

So we should strip it by self, and this feature do this.

@athurg athurg changed the title Support mysql instead of Bbolt Add support for mysql instead of Bbolt and URL prefix strip Sep 18, 2021
@Finb
Copy link
Copy Markdown
Owner

Finb commented Sep 19, 2021

Thanks for the PR 👍, support for mysql looks good, but the "URL prefix strip " seems unnecessary.

Several problems were found after testing.

  1. new device registration can not get the key ,Key returns null.
  2. When using mysql database, the registration can not generate a new key.
  3. not compatible with the existing bark.db file, for example, when sending a push, it returns "failed to get device token".

@athurg
Copy link
Copy Markdown
Author

athurg commented Sep 20, 2021

It seems the URL prefix is works fine. But the /register failed because of the new key wasn't return to the client. I have fixed that with launch arg --url-prefix=/bark. And test with some test cases:

Register:

Test with curl http://localhost:8080/bark/register -XPOST -d token=mytoken
And it response something like:

{"code":200,"message":"success","data":{"device_token":"mytoken2","key":"K4CQk9egRfuwkDhNFsEH3R","device_key":"K4CQk9egRfuwkDhNFsEH3R"},"timestamp":1632101378}

Update

Test with curl http://localhost:8080/bark/register -XPOST -d 'token=mytoken&key=MY_OLD_KEY'
Which response something like

{"code":200,"message":"success","data":{"device_key":"yvCGehiTKpXmyZHTHaoZcR","device_token":"mytoken2222,device_key=K4CQk9egRfuwkDhNFsEH3R","key":"yvCGehiTKpXmyZHTHaoZcR"},"timestamp":1632101764}

Push:

Test with curl http://localhost:8080/bark/MY_OLD_KEY/mytitle
Response like:

{"code":500,"message":"push failed: APNS push failed: BadDeviceToken","timestamp":1632101352}

PS: It's OK because the test device token is invalid.

@Finb Finb merged commit 86894d6 into Finb:master Sep 22, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants