-
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
Conversation
…plit out more helpers in router into helpers.
…plete response now available from UI. need to cache response on server side and trim what is stored.
// 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 comment
The reason will be displayed to describe this comment to others. Learn more.
clusterHandler to return cluster data from cadence server. Caches data for 1 hour.
@@ -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 comment
The reason will be displayed to describe this comment to others. Learn more.
clusterHandler to return cluster data from cadence server. Caches data for 1 hour.
@@ -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 comment
The reason will be displayed to describe this comment to others. Learn more.
clusterHandler to return cluster data from cadence server. Caches data for 1 hour.
// 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 comment
The reason will be displayed to describe this comment to others. Learn more.
Caches data for 1 hour.
method: 'DescribeCluster', | ||
requestName: 'describe', | ||
serviceName: 'AdminService', | ||
}), |
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.
clusterHandler to return cluster data from cadence server. Caches data for 1 hour.
@@ -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 comment
The reason will be displayed to describe this comment to others. Learn more.
makeChannel renamed to makeChannels and now returns 2 channels.
}) => 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 comment
The reason will be displayed to describe this comment to others. Learn more.
makeChannel renamed to makeChannels and now returns 2 channels.
responseTransform, | ||
serviceName = 'WorkflowService', |
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.
serviceName can now be passed in as an option to request. Defaults to
WorkflowService
.
const makeRequest = ({ authTokenHeaders, channel, ctx }) => ({ | ||
const makeRequest = ({ authTokenHeaders, channels, ctx }) => ({ | ||
bodyTransform, | ||
channelName = 'cadence', |
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.
channelName can now be passed in as an option to request. Defaults to
cadence
.
@@ -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 comment
The reason will be displayed to describe this comment to others. Learn more.
makeChannel renamed to makeChannels and now returns 2 channels.
@@ -38,7 +38,7 @@ module.exports = { | |||
formatMethod, | |||
formatRequestName, | |||
lookupAsync, | |||
makeChannel, | |||
makeChannels, |
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.
makeChannel renamed to makeChannels and now returns 2 channels.
@@ -19,6 +19,6 @@ | |||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | |||
// THE SOFTWARE. | |||
|
|||
const formatMethod = method => `WorkflowService::${method}`; | |||
const formatMethod = ({ method, serviceName }) => `${serviceName}::${method}`; |
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.
serviceName can now be passed in as an option to request. Defaults to
WorkflowService
.
@@ -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 comment
The 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 comment
The 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 comment
The 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.
|
||
let cache = null; | ||
|
||
const clusterHandler = async ctx => { |
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.
is the handler exposed somewhere on UI?
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.
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.
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.
LGTM, just few minor comments.
#292 will fix failing integration tests. Merged into current PR to ensure this fixes failing tests and builds are green. |
This PR is changes required by Cadence UI server to fetch data from admin service for DescribeCluster.
Because DescribeCluster is in
admin.thrift
, a new channel is needed to be setup (admin channel). This is the change made to makeChannel to return 2 channels which all other requests will use cadence channel. the new cluster handler will use the admin channel.membershipInfo
will be large in size in production so I have nulled that field for the sake of saving on size of request when making this API call. This response will be saved temporarily on the node server for 1 hour in order to save on hitting cadence server too hard as this data will not change very often (can be adjusted inrouter/constants.js
).Added
Changed
admin
andcadence
channels.cadence
.WorkflowService
.