diff --git a/.github/scripts/quickstart_go/package-lock.json b/.github/scripts/quickstart_go/package-lock.json new file mode 100644 index 0000000..378b9fe --- /dev/null +++ b/.github/scripts/quickstart_go/package-lock.json @@ -0,0 +1,198 @@ +{ + "name": "update_quickstart_go", + "version": "1.0.0", + "lockfileVersion": 3, + "requires": true, + "packages": { + "": { + "name": "update_quickstart_go", + "version": "1.0.0", + "license": "ISC", + "dependencies": { + "@octokit/request": "^8.1.1", + "@octokit/rest": "^20.0.1" + } + }, + "node_modules/@octokit/auth-token": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/@octokit/auth-token/-/auth-token-4.0.0.tgz", + "integrity": "sha512-tY/msAuJo6ARbK6SPIxZrPBms3xPbfwBrulZe0Wtr/DIY9lje2HeV1uoebShn6mx7SjCHif6EjMvoREj+gZ+SA==", + "engines": { + "node": ">= 18" + } + }, + "node_modules/@octokit/core": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/@octokit/core/-/core-5.0.0.tgz", + "integrity": "sha512-YbAtMWIrbZ9FCXbLwT9wWB8TyLjq9mxpKdgB3dUNxQcIVTf9hJ70gRPwAcqGZdY6WdJPZ0I7jLaaNDCiloGN2A==", + "dependencies": { + "@octokit/auth-token": "^4.0.0", + "@octokit/graphql": "^7.0.0", + "@octokit/request": "^8.0.2", + "@octokit/request-error": "^5.0.0", + "@octokit/types": "^11.0.0", + "before-after-hook": "^2.2.0", + "universal-user-agent": "^6.0.0" + }, + "engines": { + "node": ">= 18" + } + }, + "node_modules/@octokit/endpoint": { + "version": "9.0.0", + "resolved": "https://registry.npmjs.org/@octokit/endpoint/-/endpoint-9.0.0.tgz", + "integrity": "sha512-szrQhiqJ88gghWY2Htt8MqUDO6++E/EIXqJ2ZEp5ma3uGS46o7LZAzSLt49myB7rT+Hfw5Y6gO3LmOxGzHijAQ==", + "dependencies": { + "@octokit/types": "^11.0.0", + "is-plain-object": "^5.0.0", + "universal-user-agent": "^6.0.0" + }, + "engines": { + "node": ">= 18" + } + }, + "node_modules/@octokit/graphql": { + "version": "7.0.1", + "resolved": "https://registry.npmjs.org/@octokit/graphql/-/graphql-7.0.1.tgz", + "integrity": "sha512-T5S3oZ1JOE58gom6MIcrgwZXzTaxRnxBso58xhozxHpOqSTgDS6YNeEUvZ/kRvXgPrRz/KHnZhtb7jUMRi9E6w==", + "dependencies": { + "@octokit/request": "^8.0.1", + "@octokit/types": "^11.0.0", + "universal-user-agent": "^6.0.0" + }, + "engines": { + "node": ">= 18" + } + }, + "node_modules/@octokit/openapi-types": { + "version": "18.0.0", + "resolved": "https://registry.npmjs.org/@octokit/openapi-types/-/openapi-types-18.0.0.tgz", + "integrity": "sha512-V8GImKs3TeQRxRtXFpG2wl19V7444NIOTDF24AWuIbmNaNYOQMWRbjcGDXV5B+0n887fgDcuMNOmlul+k+oJtw==" + }, + "node_modules/@octokit/plugin-paginate-rest": { + "version": "8.0.0", + "resolved": "https://registry.npmjs.org/@octokit/plugin-paginate-rest/-/plugin-paginate-rest-8.0.0.tgz", + "integrity": "sha512-2xZ+baZWUg+qudVXnnvXz7qfrTmDeYPCzangBVq/1gXxii/OiS//4shJp9dnCCvj1x+JAm9ji1Egwm1BA47lPQ==", + "dependencies": { + "@octokit/types": "^11.0.0" + }, + "engines": { + "node": ">= 18" + }, + "peerDependencies": { + "@octokit/core": ">=5" + } + }, + "node_modules/@octokit/plugin-request-log": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/@octokit/plugin-request-log/-/plugin-request-log-4.0.0.tgz", + "integrity": "sha512-2uJI1COtYCq8Z4yNSnM231TgH50bRkheQ9+aH8TnZanB6QilOnx8RMD2qsnamSOXtDj0ilxvevf5fGsBhBBzKA==", + "engines": { + "node": ">= 18" + }, + "peerDependencies": { + "@octokit/core": ">=5" + } + }, + "node_modules/@octokit/plugin-rest-endpoint-methods": { + "version": "9.0.0", + "resolved": "https://registry.npmjs.org/@octokit/plugin-rest-endpoint-methods/-/plugin-rest-endpoint-methods-9.0.0.tgz", + "integrity": "sha512-KquMF/VB1IkKNiVnzJKspY5mFgGyLd7HzdJfVEGTJFzqu9BRFNWt+nwTCMuUiWc72gLQhRWYubTwOkQj+w/1PA==", + "dependencies": { + "@octokit/types": "^11.0.0" + }, + "engines": { + "node": ">= 18" + }, + "peerDependencies": { + "@octokit/core": ">=5" + } + }, + "node_modules/@octokit/request": { + "version": "8.1.1", + "resolved": "https://registry.npmjs.org/@octokit/request/-/request-8.1.1.tgz", + "integrity": "sha512-8N+tdUz4aCqQmXl8FpHYfKG9GelDFd7XGVzyN8rc6WxVlYcfpHECnuRkgquzz+WzvHTK62co5di8gSXnzASZPQ==", + "dependencies": { + "@octokit/endpoint": "^9.0.0", + "@octokit/request-error": "^5.0.0", + "@octokit/types": "^11.1.0", + "is-plain-object": "^5.0.0", + "universal-user-agent": "^6.0.0" + }, + "engines": { + "node": ">= 18" + } + }, + "node_modules/@octokit/request-error": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/@octokit/request-error/-/request-error-5.0.0.tgz", + "integrity": "sha512-1ue0DH0Lif5iEqT52+Rf/hf0RmGO9NWFjrzmrkArpG9trFfDM/efx00BJHdLGuro4BR/gECxCU2Twf5OKrRFsQ==", + "dependencies": { + "@octokit/types": "^11.0.0", + "deprecation": "^2.0.0", + "once": "^1.4.0" + }, + "engines": { + "node": ">= 18" + } + }, + "node_modules/@octokit/rest": { + "version": "20.0.1", + "resolved": "https://registry.npmjs.org/@octokit/rest/-/rest-20.0.1.tgz", + "integrity": "sha512-wROV21RwHQIMNb2Dgd4+pY+dVy1Dwmp85pBrgr6YRRDYRBu9Gb+D73f4Bl2EukZSj5hInq2Tui9o7gAQpc2k2Q==", + "dependencies": { + "@octokit/core": "^5.0.0", + "@octokit/plugin-paginate-rest": "^8.0.0", + "@octokit/plugin-request-log": "^4.0.0", + "@octokit/plugin-rest-endpoint-methods": "^9.0.0" + }, + "engines": { + "node": ">= 18" + } + }, + "node_modules/@octokit/types": { + "version": "11.1.0", + "resolved": "https://registry.npmjs.org/@octokit/types/-/types-11.1.0.tgz", + "integrity": "sha512-Fz0+7GyLm/bHt8fwEqgvRBWwIV1S6wRRyq+V6exRKLVWaKGsuy6H9QFYeBVDV7rK6fO3XwHgQOPxv+cLj2zpXQ==", + "dependencies": { + "@octokit/openapi-types": "^18.0.0" + } + }, + "node_modules/before-after-hook": { + "version": "2.2.3", + "resolved": "https://registry.npmjs.org/before-after-hook/-/before-after-hook-2.2.3.tgz", + "integrity": "sha512-NzUnlZexiaH/46WDhANlyR2bXRopNg4F/zuSA3OpZnllCUgRaOF2znDioDWrmbNVsuZk6l9pMquQB38cfBZwkQ==" + }, + "node_modules/deprecation": { + "version": "2.3.1", + "resolved": "https://registry.npmjs.org/deprecation/-/deprecation-2.3.1.tgz", + "integrity": "sha512-xmHIy4F3scKVwMsQ4WnVaS8bHOx0DmVwRywosKhaILI0ywMDWPtBSku2HNxRvF7jtwDRsoEwYQSfbxj8b7RlJQ==" + }, + "node_modules/is-plain-object": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/is-plain-object/-/is-plain-object-5.0.0.tgz", + "integrity": "sha512-VRSzKkbMm5jMDoKLbltAkFQ5Qr7VDiTFGXxYFXXowVj387GeGNOCsOH6Msy00SGZ3Fp84b1Naa1psqgcCIEP5Q==", + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/once": { + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/once/-/once-1.4.0.tgz", + "integrity": "sha512-lNaJgI+2Q5URQBkccEKHTQOPaXdUxnZZElQTZY0MFUAuaEqe1E+Nyvgdz/aIyNi6Z9MzO5dv1H8n58/GELp3+w==", + "dependencies": { + "wrappy": "1" + } + }, + "node_modules/universal-user-agent": { + "version": "6.0.0", + "resolved": "https://registry.npmjs.org/universal-user-agent/-/universal-user-agent-6.0.0.tgz", + "integrity": "sha512-isyNax3wXoKaulPDZWHQqbmIx1k2tb9fb3GGDBRxCscfYV2Ch7WxPArBsFEG8s/safwXTT7H4QGhaIkTp9447w==" + }, + "node_modules/wrappy": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz", + "integrity": "sha512-l4Sp/DRseor9wL6EvV2+TuQn63dMkPjZ/sp9XkghTEbV9KlPS1xUsZ3u7/IQO4wxtcFB4bgpQPRcR3QCvezPcQ==" + } + } + } \ No newline at end of file diff --git a/.github/scripts/quickstart_go/package.json b/.github/scripts/quickstart_go/package.json new file mode 100644 index 0000000..fa3fd45 --- /dev/null +++ b/.github/scripts/quickstart_go/package.json @@ -0,0 +1,17 @@ +{ + "name": "update_quickstart_go", + "version": "1.0.0", + "description": "Scrapes readme's hopefully", + "main": "update_quickstart_go.js", + "scripts": { + "test": "echo \"Error: no test specified\" && exit 1", + "run": "node update_quickstart_go.js" + }, + "author": "Memphis", + "license": "ISC", + "type": "module", + "dependencies": { + "@octokit/request": "^8.1.1", + "@octokit/rest": "^20.0.1" + } + } \ No newline at end of file diff --git a/.github/scripts/quickstart_go/update_quickstart_go.js b/.github/scripts/quickstart_go/update_quickstart_go.js new file mode 100644 index 0000000..81ebde1 --- /dev/null +++ b/.github/scripts/quickstart_go/update_quickstart_go.js @@ -0,0 +1,85 @@ +const git_token = process.env.DOCS_ACTION_TOKEN + +import { Octokit } from "@octokit/rest"; + +const octokit = new Octokit({ + auth: git_token + }) + +const repos = [ + { + repo_name: 'memphis.go', + doc_path: 'docs/sdk/client-libraries/go/quick-start.md', + language_name: 'Go' + }, +] + +let did_error = false; +const failed_languages = []; +for (let repo of repos){ + try { + await update_file(repo.repo_name, repo.doc_path, repo.language_name) + } catch (error) { + console.log();(error); + did_error = true; + failed_languages.push(repo.language_name) + } +} + +if (did_error){ + throw new Error(`Failed to update one or more languages. \n Failed Languages: ${failed_languages.join(', ')}`) +} + +async function update_file(repo_name, doc_path, language_name){ + console.log(`Updating ${language_name} Quickstart`); + console.log(`Repo: ${repo_name}`); + + console.log(`Getting ${language_name} README`); + let req = await octokit.request('GET /repos/{owner}/{repo}/contents/{path}', { + owner: 'memphisdev', + repo: repo_name, + path: 'README.md', + headers: { + 'X-GitHub-Api-Version': '2022-11-28' + } +}) + + console.log(`Getting ${language_name} Quickstart SHA`); + let quick_start = await octokit.request('GET /repos/{owner}/{repo}/contents/{path}', { + owner: 'memphisdev', + repo: 'documentation', + path: doc_path, + headers: { + 'X-GitHub-Api-Version': '2022-11-28' + } + }) + + const quick_start_sha = quick_start.data.sha; + + console.log(`Quickstart SHA: ${quick_start_sha}`); + + const readme_content = atob(req.data.content) + const readme_h3_to_h2 = readme_content.replace(/###/g, '##') + const commit_string = `--- + title: ${language_name} Quickstart + description: A quickstart on how to use the ${language_name} client library +---`+ '\n' + readme_h3_to_h2 + + console.log(`Updating ${language_name} Quickstart`); + await octokit.request('PUT /repos/{owner}/{repo}/contents/{path}', { + owner: 'memphisdev', + repo: 'documentation', + path: doc_path, + message: `Updating ${language_name} SDK Quick-Start`, + committer: { + name: 'Automated Workflow', + email: 'john@memphis.dev' + }, + content: btoa(commit_string), + headers: { + 'X-GitHub-Api-Version': '2022-11-28' + }, + sha: quick_start_sha + }) +} + diff --git a/.github/workflows/auto_update_quick_start.yml b/.github/workflows/auto_update_quick_start.yml new file mode 100644 index 0000000..c5e911e --- /dev/null +++ b/.github/workflows/auto_update_quick_start.yml @@ -0,0 +1,25 @@ +name: Auto-Update Go Quickstart Page +on: + push: + branches: + - latest +jobs: + update: + runs-on: ubuntu-latest + steps: + - name: Checkout repo + uses: actions/checkout@v3 + with: + sparse-checkout: .github + - name: Setup Node + uses: actions/setup-node@v3 + with: + node-version: 'latest' + - name: Run quickstart script + env: + REPO_TOKEN: ${{ secrets.DOCS_ACTION_TOKEN }} + run: | + cd ./.github/scripts/quickstart_go + ls + npm ci + node update_quickstart_go.js diff --git a/connect.go b/connect.go index b155fd6..1155e0d 100644 --- a/connect.go +++ b/connect.go @@ -360,14 +360,15 @@ func (c *Conn) startConn() error { var err error url := opts.Host + ":" + strconv.Itoa(opts.Port) natsOpts := nats.Options{ - Url: url, - AllowReconnect: opts.Reconnect, - MaxReconnect: opts.MaxReconnect, - ReconnectWait: opts.ReconnectInterval, - Timeout: opts.Timeout, - DisconnectedErrCB: disconnectedError, - Name: c.ConnId + "::" + opts.Username, - ClosedCB: DefaultErrHandler, + Url: url, + AllowReconnect: opts.Reconnect, + MaxReconnect: opts.MaxReconnect, + ReconnectWait: opts.ReconnectInterval, + Timeout: opts.Timeout, + DisconnectedErrCB: disconnectedError, + Name: c.ConnId + "::" + opts.Username, + ClosedCB: DefaultErrHandler, + RetryOnFailedConnect: false, } if opts.ConnectionToken != "" { diff --git a/consumer.go b/consumer.go index 0e81136..fb362a3 100644 --- a/consumer.go +++ b/consumer.go @@ -383,11 +383,17 @@ func (c *Consumer) pingConsumer() { }(sub) } wg.Wait() +<<<<<<< HEAD if generalErr != nil { if strings.Contains(generalErr.Error(), "consumer not found") || strings.Contains(generalErr.Error(), "stream not found") { c.subscriptionActive = false c.callErrHandler(ConsumerErrStationUnreachable) } +======= + if generalErr != nil && (strings.Contains(generalErr.Error(), "consumer not found") || strings.Contains(generalErr.Error(), "stream not found")) { + c.subscriptionActive = false + c.callErrHandler(ConsumerErrStationUnreachable) +>>>>>>> origin/master } case <-c.pingQuit: ticker.Stop() diff --git a/version-beta.conf b/version-beta.conf index 55bded1..cfc52bc 100644 --- a/version-beta.conf +++ b/version-beta.conf @@ -1 +1 @@ -1.1.2-beta.1 \ No newline at end of file +1.1.3-beta.1 \ No newline at end of file