• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

TypeScript minimal.util类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了TypeScript中protobufjs/minimal.util的典型用法代码示例。如果您正苦于以下问题:TypeScript util类的具体用法?TypeScript util怎么用?TypeScript util使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



在下文中一共展示了util类的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的TypeScript代码示例。

示例1: getEventDescription

export function getEventDescription(e: Event$Properties): string {
  const info: {
    DatabaseName: string,
    DroppedTables: string[],
    IndexName: string,
    MutationID: string,
    TableName: string,
    User: string,
    ViewName: string,
    SettingName: string,
    Value: string,
  } = protobuf.util.isset(e, "info") ? JSON.parse(e.info) : {};
  const targetId: number = e.target_id ? e.target_id.toNumber() : null;

  switch (e.event_type) {
    case eventTypes.CREATE_DATABASE:
      return `Database Created: User ${info.User} created database ${info.DatabaseName}`;
    case eventTypes.DROP_DATABASE:
      info.DroppedTables = info.DroppedTables || [];
      let tableDropText: string = `${info.DroppedTables.length} tables were dropped: ${info.DroppedTables.join(", ")}`;
      if (info.DroppedTables.length === 0) {
        tableDropText = "No tables were dropped.";
      } else if (info.DroppedTables.length === 1) {
        tableDropText = `1 table was dropped: ${info.DroppedTables[0]}`;
      }
      return `Database Dropped: User ${info.User} dropped database ${info.DatabaseName}.${tableDropText}`;
    case eventTypes.CREATE_TABLE:
      return `Table Created: User ${info.User} created table ${info.TableName}`;
    case eventTypes.DROP_TABLE:
      return `Table Dropped: User ${info.User} dropped table ${info.TableName}`;
    case eventTypes.ALTER_TABLE:
      return `Schema Change: User ${info.User} began a schema change to alter table ${info.TableName} with ID ${info.MutationID}`;
    case eventTypes.CREATE_INDEX:
      return `Schema Change: User ${info.User} began a schema change to create an index ${info.IndexName} on table ${info.TableName} with ID ${info.MutationID}`;
    case eventTypes.DROP_INDEX:
      return `Schema Change: User ${info.User} began a schema change to drop index ${info.IndexName} on table ${info.TableName} with ID ${info.MutationID}`;
    case eventTypes.CREATE_VIEW:
      return `View Created: User ${info.User} created view ${info.ViewName}`;
    case eventTypes.DROP_VIEW:
      return `View Dropped: User ${info.User} dropped view ${info.ViewName}`;
    case eventTypes.REVERSE_SCHEMA_CHANGE:
      return `Schema Change Reversed: Schema change with ID ${info.MutationID} was reversed.`;
    case eventTypes.FINISH_SCHEMA_CHANGE:
      return `Schema Change Completed: Schema change with ID ${info.MutationID} was completed.`;
    case eventTypes.FINISH_SCHEMA_CHANGE_ROLLBACK:
      return `Schema Change Rollback Completed: Rollback of schema change with ID ${info.MutationID} was completed.`;
    case eventTypes.NODE_JOIN:
      return `Node Joined: Node ${targetId} joined the cluster`;
    case eventTypes.NODE_DECOMMISSIONED:
      return `Node Decommissioned: Node ${targetId} was decommissioned`;
    case eventTypes.NODE_RECOMMISSIONED:
      return `Node Recommissioned: Node ${targetId} was recommissioned`;
    case eventTypes.NODE_RESTART:
      return `Node Rejoined: Node ${targetId} rejoined the cluster`;
    case eventTypes.SET_CLUSTER_SETTING:
      return `Cluster Setting Changed: User ${info.User} set ${info.SettingName} to ${info.Value}`;
    default:
      return `Unknown Event Type: ${e.event_type}, content: ${JSON.stringify(info, null, 2)}`;
  }
}
开发者ID:boreys,项目名称:cockroach,代码行数:60,代码来源:events.ts


示例2: getEventDescription

export function getEventDescription(e: Event$Properties): string {
  const info: EventInfo = protobuf.util.isset(e, "info") ? JSON.parse(e.info) : {};
  const targetId: number = e.target_id ? e.target_id.toNumber() : null;

  switch (e.event_type) {
    case eventTypes.CREATE_DATABASE:
      return `Database Created: User ${info.User} created database ${info.DatabaseName}`;
    case eventTypes.DROP_DATABASE:
      const tableDropText = getDroppedObjectsText(info);
      return `Database Dropped: User ${info.User} dropped database ${info.DatabaseName}. ${tableDropText}`;
    case eventTypes.CREATE_TABLE:
      return `Table Created: User ${info.User} created table ${info.TableName}`;
    case eventTypes.DROP_TABLE:
      return `Table Dropped: User ${info.User} dropped table ${info.TableName}`;
    case eventTypes.TRUNCATE_TABLE:
      return `Table Truncated: User ${info.User} truncated table ${info.TableName}`;
    case eventTypes.ALTER_TABLE:
      return `Schema Change: User ${info.User} began a schema change to alter table ${info.TableName} with ID ${info.MutationID}`;
    case eventTypes.CREATE_INDEX:
      return `Schema Change: User ${info.User} began a schema change to create an index ${info.IndexName} on table ${info.TableName} with ID ${info.MutationID}`;
    case eventTypes.DROP_INDEX:
      return `Schema Change: User ${info.User} began a schema change to drop index ${info.IndexName} on table ${info.TableName} with ID ${info.MutationID}`;
    case eventTypes.ALTER_INDEX:
      return `Schema Change: User ${info.User} began a schema change to alter index ${info.IndexName} on table ${info.TableName} with ID ${info.MutationID}`;
    case eventTypes.CREATE_VIEW:
      return `View Created: User ${info.User} created view ${info.ViewName}`;
    case eventTypes.DROP_VIEW:
      return `View Dropped: User ${info.User} dropped view ${info.ViewName}`;
    case eventTypes.CREATE_SEQUENCE:
      return `Sequence Created: User ${info.User} created sequence ${info.SequenceName}`;
    case eventTypes.ALTER_SEQUENCE:
      return `Sequence Altered: User ${info.User} altered sequence ${info.SequenceName}`;
    case eventTypes.DROP_SEQUENCE:
      return `Sequence Dropped: User ${info.User} dropped sequence ${info.SequenceName}`;
    case eventTypes.REVERSE_SCHEMA_CHANGE:
      return `Schema Change Reversed: Schema change with ID ${info.MutationID} was reversed.`;
    case eventTypes.FINISH_SCHEMA_CHANGE:
      return `Schema Change Completed: Schema change with ID ${info.MutationID} was completed.`;
    case eventTypes.FINISH_SCHEMA_CHANGE_ROLLBACK:
      return `Schema Change Rollback Completed: Rollback of schema change with ID ${info.MutationID} was completed.`;
    case eventTypes.NODE_JOIN:
      return `Node Joined: Node ${targetId} joined the cluster`;
    case eventTypes.NODE_DECOMMISSIONED:
      return `Node Decommissioned: Node ${targetId} was decommissioned`;
    case eventTypes.NODE_RECOMMISSIONED:
      return `Node Recommissioned: Node ${targetId} was recommissioned`;
    case eventTypes.NODE_RESTART:
      return `Node Rejoined: Node ${targetId} rejoined the cluster`;
    case eventTypes.SET_CLUSTER_SETTING:
      if (info.Value && info.Value.length > 0) {
        return `Cluster Setting Changed: User ${info.User} set ${info.SettingName} to ${info.Value}`;
      }
      return `Cluster Setting Changed: User ${info.User} changed ${info.SettingName}`;
    case eventTypes.SET_ZONE_CONFIG:
    return `Zone Config Changed: User ${info.User} set the zone config for ${info.Target} to ${info.Config}`;
    case eventTypes.REMOVE_ZONE_CONFIG:
      return `Zone Config Removed: User ${info.User} removed the zone config for ${info.Target}`;
    default:
      return `Unknown Event Type: ${e.event_type}, content: ${JSON.stringify(info, null, 2)}`;
  }
}
开发者ID:a6802739,项目名称:cockroach,代码行数:61,代码来源:events.ts



注:本文中的protobufjs/minimal.util类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
TypeScript receiver.Receiver类代码示例发布时间:2022-05-25
下一篇:
TypeScript protobufjs.load函数代码示例发布时间:2022-05-25
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap