Skip to content
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

Merged
merged 35 commits into from
Apr 27, 2021
Merged

Feature/es support server #291

merged 35 commits into from
Apr 27, 2021

Conversation

just-at-uber
Copy link
Contributor

@just-at-uber just-at-uber commented Apr 23, 2021

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 in router/constants.js).

Added

  • clusterHandler to return cluster data from cadence server. Caches data for 1 hour.

Changed

  • makeChannel renamed to makeChannels and now returns 2 channels. returns admin and cadence channels.
  • channelName can now be passed in as an option to request. Defaults to cadence.
  • serviceName can now be passed in as an option to request. Defaults to WorkflowService.

// 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.
Copy link
Contributor Author

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);
Copy link
Contributor Author

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');
Copy link
Contributor Author

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;
Copy link
Contributor Author

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',
}),
Copy link
Contributor Author

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);
Copy link
Contributor Author

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(
Copy link
Contributor Author

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',
Copy link
Contributor Author

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',
Copy link
Contributor Author

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 => {
Copy link
Contributor Author

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,
Copy link
Contributor Author

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}`;
Copy link
Contributor Author

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.

@just-at-uber just-at-uber marked this pull request as ready for review April 26, 2021 17:47
@just-at-uber just-at-uber requested a review from a team April 26, 2021 17:47
@@ -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 }) => ({

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?

Copy link
Contributor Author

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.

Copy link
Contributor Author

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 => {

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?

Copy link
Contributor Author

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.

Copy link

@mkolodezny mkolodezny left a 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.

@just-at-uber
Copy link
Contributor Author

just-at-uber commented Apr 27, 2021

#292 will fix failing integration tests. Merged into current PR to ensure this fixes failing tests and builds are green.

@just-at-uber just-at-uber merged commit c6c2b0b into master Apr 27, 2021
@just-at-uber just-at-uber deleted the feature/es-support-server branch April 27, 2021 18:34
@just-at-uber just-at-uber mentioned this pull request May 27, 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