-
Notifications
You must be signed in to change notification settings - Fork 107
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feature/es support server #291
Changes from all commits
b2457b9
aec6f41
896cb5a
4e8de81
12989de
6952a2e
c17d10a
366f3a5
91ce070
dff0856
59dd932
5117b29
9a80a84
5447c1b
ccd8f49
21eeb7e
1412c2f
bdd718a
9dbcd34
6536ad7
a1520d0
a7f0b27
d2587f0
042ce11
c57c35e
73173aa
9e4321e
466d1ac
7548afd
d9a1a9a
61f28b5
c6d59b9
ea4b459
b91ddf3
153436d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -24,7 +24,7 @@ const formatBody = require('./format-body'); | |
const formatMethod = require('./format-method'); | ||
const formatRequestName = require('./format-request-name'); | ||
const lookupAsync = require('./lookup-async'); | ||
const makeChannel = require('./make-channel'); | ||
const makeChannels = require('./make-channels'); | ||
const makeRequest = require('./make-request'); | ||
const uiTransform = require('./ui-transform'); | ||
const withDomainPagingAndWorkflowExecution = require('./with-domain-paging-and-workflow-execution'); | ||
|
@@ -38,7 +38,7 @@ module.exports = { | |
formatMethod, | ||
formatRequestName, | ||
lookupAsync, | ||
makeChannel, | ||
makeChannels, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
makeRequest, | ||
uiTransform, | ||
withDomainPagingAndWorkflowExecution, | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -25,7 +25,7 @@ const TChannelAsThrift = require('tchannel/as/thrift'); | |
const { PEERS } = require('../constants'); | ||
const lookupAsync = require('./lookup-async'); | ||
|
||
const makeChannel = async client => { | ||
const makeChannels = async client => { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
const ipPeers = await Promise.all( | ||
PEERS.map(peer => { | ||
const [host, port] = peer.split(':'); | ||
|
@@ -47,12 +47,20 @@ const makeChannel = async client => { | |
}, | ||
}); | ||
|
||
const tchannelAsThrift = TChannelAsThrift({ | ||
const adminTChannelAsThrift = TChannelAsThrift({ | ||
channel: cadenceChannel, | ||
entryPoint: path.join(__dirname, '../../../idl/admin.thrift'), | ||
}); | ||
|
||
const cadenceTChannelAsThrift = TChannelAsThrift({ | ||
channel: cadenceChannel, | ||
entryPoint: path.join(__dirname, '../../../idl/cadence.thrift'), | ||
}); | ||
|
||
return tchannelAsThrift; | ||
return { | ||
admin: adminTChannelAsThrift, | ||
cadence: cadenceTChannelAsThrift, | ||
}; | ||
}; | ||
|
||
module.exports = makeChannel; | ||
module.exports = makeChannels; |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -25,16 +25,18 @@ const formatMethod = require('./format-method'); | |
const formatRequestName = require('./format-request-name'); | ||
const uiTransform = require('./ui-transform'); | ||
|
||
const makeRequest = ({ authTokenHeaders, channel, ctx }) => ({ | ||
const makeRequest = ({ authTokenHeaders, channels, ctx }) => ({ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. do we use the same auth token for the both channels? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It's a good question. I need to be able to test this in staging to know whether we need different credentials. Right now I'm not sure. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It shouldn't be a massive change in the event it does need separate credentials. |
||
bodyTransform, | ||
channelName = 'cadence', | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
method, | ||
requestName, | ||
bodyTransform, | ||
responseTransform, | ||
serviceName = 'WorkflowService', | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
}) => body => | ||
new Promise((resolve, reject) => { | ||
try { | ||
channel.request(REQUEST_CONFIG).send( | ||
formatMethod(method), | ||
channels[channelName].request(REQUEST_CONFIG).send( | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
formatMethod({ method, serviceName }), | ||
{ | ||
...authTokenHeaders, | ||
}, | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -25,7 +25,7 @@ const TChannel = require('tchannel'); | |
|
||
const { | ||
cliTransform, | ||
makeChannel, | ||
makeChannels, | ||
makeRequest, | ||
withDomainPaging, | ||
withWorkflowExecution, | ||
|
@@ -37,10 +37,10 @@ const tchannelClient = async function(ctx, next) { | |
const { authTokenHeaders = {} } = ctx; | ||
|
||
const client = TChannel(); | ||
const channel = await makeChannel(client); | ||
const channels = await makeChannels(client); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
const request = makeRequest({ | ||
authTokenHeaders, | ||
channel, | ||
channels, | ||
ctx, | ||
}); | ||
|
||
|
@@ -55,6 +55,12 @@ const tchannelClient = async function(ctx, next) { | |
requestName: 'list', | ||
bodyTransform: withDomainPaging(ctx), | ||
}), | ||
describeCluster: request({ | ||
channelName: 'admin', | ||
method: 'DescribeCluster', | ||
requestName: 'describe', | ||
serviceName: 'AdminService', | ||
}), | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
describeDomain: request({ | ||
method: 'DescribeDomain', | ||
requestName: 'describe', | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
// Copyright (c) 2021 Uber Technologies Inc. | ||
// | ||
// | ||
// Permission is hereby granted, free of charge, to any person obtaining a copy | ||
// of this software and associated documentation files (the "Software"), to deal | ||
// in the Software without restriction, including without limitation the rights | ||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
// copies of the Software, and to permit persons to whom the Software is | ||
// furnished to do so, subject to the following conditions: | ||
// | ||
// The above copyright notice and this permission notice shall be included in | ||
// all copies or substantial portions of the Software. | ||
// | ||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | ||
// THE SOFTWARE. | ||
|
||
const ONE_HOUR_IN_MILLISECONDS = 60 * 60 * 1000; | ||
const CLUSTER_CACHE_TTL = ONE_HOUR_IN_MILLISECONDS; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
|
||
module.exports = { | ||
CLUSTER_CACHE_TTL, | ||
}; |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -22,6 +22,7 @@ | |
const Router = require('koa-router'); | ||
|
||
const { | ||
clusterHandler, | ||
domainAuthorizationHandler, | ||
domainHandler, | ||
domainListHandler, | ||
|
@@ -45,7 +46,10 @@ const { listWorkflows } = require('./helpers'); | |
|
||
const router = new Router(); | ||
|
||
router.get('/api/cluster', clusterHandler); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
|
||
router.get('/api/domains', domainListHandler); | ||
|
||
router.get('/api/domains/:domain', domainHandler); | ||
|
||
/** | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
// Copyright (c) 2021 Uber Technologies Inc. | ||
// | ||
// | ||
// Permission is hereby granted, free of charge, to any person obtaining a copy | ||
// of this software and associated documentation files (the "Software"), to deal | ||
// in the Software without restriction, including without limitation the rights | ||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
// copies of the Software, and to permit persons to whom the Software is | ||
// furnished to do so, subject to the following conditions: | ||
// | ||
// The above copyright notice and this permission notice shall be included in | ||
// all copies or substantial portions of the Software. | ||
// | ||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | ||
// THE SOFTWARE. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
|
||
const { CLUSTER_CACHE_TTL } = require('../constants'); | ||
|
||
let cache = null; | ||
|
||
const clusterHandler = async ctx => { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. is the handler exposed somewhere on UI? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It will be eventually, right now this is only containing the server side code changes. will raise separate PR which hooks this up in the frontend. |
||
if (cache) { | ||
return (ctx.body = cache); | ||
} | ||
|
||
const cluster = await ctx.cadence.describeCluster(); | ||
|
||
cache = { ...cluster, membershipInfo: null }; | ||
ctx.body = cache; | ||
|
||
// This timeout will clear cache after TTL period. | ||
// It will fetch a new value on the next request to clusterHandler. | ||
setTimeout(() => (cache = null), CLUSTER_CACHE_TTL); | ||
}; | ||
|
||
module.exports = clusterHandler; |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -19,6 +19,7 @@ | |
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | ||
// THE SOFTWARE. | ||
|
||
const clusterHandler = require('./cluster-handler'); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
const domainAuthorizationHandler = require('./domain-authorization-handler'); | ||
const domainHandler = require('./domain-handler'); | ||
const domainListHandler = require('./domain-list-handler'); | ||
|
@@ -38,6 +39,7 @@ const workflowSignalHandler = require('./workflow-signal-handler'); | |
const workflowTerminateHandler = require('./workflow-terminate-handler'); | ||
|
||
module.exports = { | ||
clusterHandler, | ||
domainAuthorizationHandler, | ||
domainHandler, | ||
domainListHandler, | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.