首页 文章 精选 留言 我的

精选列表

搜索[EdgeOneMakersAgent案例],共10000篇文章
优秀的个人博客,低调大师

Kiro 技术功能与案例分析

Kiro 是一个面向现代开发团队的轻量级、高性能的任务编排与自动化引擎。它借鉴了工作流引擎的设计理念,但又避免了传统 BPMN 的重型配置,专注于用简洁的 YAML 描述将多个工具、脚本和 API 串联成可靠的自动化流水线。无论是 CI/CD 中的复杂部署流程,还是数据处理中的 ETL 管道,Kiro 都能以极低的接入成本提供可观测、可重试、可回滚的编排能力。

优秀的个人博客,低调大师

20210111 装饰器之案例剖析

高阶函数a: 把一个函数名当做实参传给另外一个函数(在不修改被装饰函数源代码的情况下为其添加功能)b: 返回值中包含函数名(不修改函数的调用方式) # 现在写一个装饰器 # 两个函数都有自己的逻辑,能够实现自己的功能 # 写一个装饰器,统计函数运行时间 1-1 import time def test1(): time.sleep(3) print('in the test1') def test2(): time.sleep(3) print('in the test2') # 统计test1 和 test2 的运行时间,但是前提是不能修改调用方式 1-1-1 # 如何不修改源代码,给 test1 新增一个功能? import time def test1(): time.sleep(3) print('in the test1') def test2(): time.sleep(3) print('in the test2') # 写一个高阶函数 def deco(func): start_time = time.time() func() stop_time = time.time() print("the func run time is %s" %(stop_time-start_time)) # 那么怎么用? # 为什么 test1 不加括号,因为test1(),传入的是返回值结果 deco(test1) deco(test2) ---> in the test1 the func run time is 3.0043373107910156 in the test2 the func run time is 3.0002830028533936 1-1-2 # 1-1-1 修改了函数的调用方式 # 如何不修改函数的调用方式? # 第二类高阶函数,不改变函数的调用方式,在使用的时候就是 test1 = deco(test1) 这种方式 # 但是前提是 需要把函数修改成 用 return 返回函数名的 第二种形式的高阶函数 # 这样,test1 就可以获取 deco 的返回值,deco 的返回值就是 test1 的 内存地址 # test1() 可以正常调用,test2()也可以 def deco(func): start_time = time.time() return func stop_time = time.time() print("the func run time is %s" %(stop_time-start_time)) import time def test1(): time.sleep(3) print('in the test1') def test2(): time.sleep(3) print('in the test2') test1 = deco(test1) test1() test2 = deco(test2) test2() ---> in the test1 in the test2 # 没有修改函数的调用方式,也没有新增功能,什么都没有做 # 为什么是这样呢? # 因为 deco 中的 return,直接调用了 test1; # 之后的内容不会执行,这就是 return 的一个特性 1-1-3 # 因为 1-1-2 中一直在用高阶函数,漏掉了嵌套 # 可以引入嵌套函数 def deco(func): start_time = time.time() return func stop_time = time.time() print("the func run time is %s" %(stop_time-start_time)) def timer(): def deco(): pass # 这是嵌套函数,如何把这个函数,融入到上面的 deco中呢? 1-1-4 import time def timer(func): # timer(test1) 把 test1 的内存地址 传给 func = test1 def deco(): start_time = time.time() func() stop_time = time.time() print("the func run time is %s" %(stop_time-start_time)) return deco # 返回 deco 函数的内存地址 # 这么做以后,用到了高阶函数,用到了函数嵌套 def test1(): time.sleep(3) print('in the test1') def test2(): time.sleep(3) print('in the test2') timer(test1) print(timer(test1)) # 返回 deco 的内存地址 ---> <function timer.<locals>.deco at 0x000002C818B1D558> 1-2 # 想要调用 timer(test1) 应该怎么做? # 给它赋值,然后 test1 执行就可以 import time def timer(func): # timer(test1) 把 test1 的内存地址 传给 func = test1 def deco(): start_time = time.time() func() # run test1() stop_time = time.time() print("the func run time is %s" %(stop_time-start_time)) return deco # 返回 deco 函数的内存地址 # 这么做以后,用到了高阶函数,用到了函数嵌套 def test1(): time.sleep(3) print('in the test1') def test2(): time.sleep(3) print('in the test2') test1=timer(test1) test1() # 这时候,test1 执行,实际上是在执行 deco 函数,因为 timer 返回的是 deco;deco做的事情是计算时间; func 的值是 test1 的值 ---> in the test1 the func run time is 3.000483751296997 # 成功加了一个新功能,没有改变源代码和调用方式; # 用到函数的嵌套,引用高阶函数的定义,最终实现这样的效果 1-3 # 但是 1-2 那样 # test1=timer(test1) # test1() # 这种方式,有些麻烦;每次都需要运行装饰器,运行一个和原来函数名一样的东西 # 如何直接 test1() 运行呢? # 解释器提供了一种语法,直接加 @timer;@ 后加上装饰器的名字;写在想要新增功能的函数的头部 # @timer 就等同于 test1 = timer(test1) 这部操作 import time def timer(func): def deco(): start_time = time.time() func() stop_time = time.time() print("the func run time is %s" %(stop_time-start_time)) return deco @timer def test1(): time.sleep(3) print('in the test1') @timer def test2(): time.sleep(3) print('in the test2') test1() test2() ---> in the test1 the func run time is 3.000530958175659 in the test2 the func run time is 3.000612497329712 # 这两个函数正常运行了,同时加上了新功能 1-1 # 如果 test2 里面有一个参数 import time def timer(func): def deco(): start_time = time.time() func() stop_time = time.time() print("the func run time is %s" %(stop_time-start_time)) return deco @timer def test1(): time.sleep(3) print('in the test1') @timer def test2(name): print("test2:",name) test1() test2() ---> TypeError: test2() missing 1 required positional argument: 'name' # 结果是出错的,test2 缺少位置参数 name # @timer 相当于 test2 = timer(test2) # test2 传到里面都做了什么? test2 → func → 执行 deco 所以,内嵌的deco函数,执行了吗? # return deco,直接返回了 deco 的内存地址 # test2 其实是等于 deco,于是 test2()相当于 deco(),执行到 func()时,相当于执行到了 test2() # 但是 test2 是要求传参数的,test2()没有传参;所以会报错 # 那么,这种情况应该如何处理?如何把参数传进来? 1-2 # test2(name),其实就是相当于 deco(name) import time def timer(func): def deco(arg1): start_time = time.time() func(arg1) stop_time = time.time() print("the func run time is %s" %(stop_time-start_time)) return deco @timer def test2(name): print("test2:",name) test2("alex") ---> test2: alex the func run time is 0.0 1-2-1 # 如果传入两个参数呢? # 要装饰的函数可能是各种各样的功能 # 所以需要 *args **kwargs import time def timer(func): def deco(*args,**kwargs): start_time = time.time() func(*args,**kwargs) stop_time = time.time() print("the func run time is %s" %(stop_time-start_time)) return deco @timer def test1(): time.sleep(3) print('in the test1') @timer def test2(name,age): print("test2:",name,age) test1() test2("alex",11) ---> in the test1 the func run time is 3.0008721351623535 test2: alex 11 the func run time is 0.0009975433349609375

优秀的个人博客,低调大师

Timing App的Serverless实践案例

1、背景和挑战: 作为广受好评的学习应用,Timing App 专注于帮助社区用户提升学习凝聚力,达成学习目标。目前已有超过 700 万人通过 Timing 进行高效学习。与传统在线学习应用不同,Timing app 提供了 Timing 自习室、图书馆学习、 视频打卡、学习日记、契约群、学习服务等多类具有社交性质的在线教育服务,帮助用户找到自己的学习节奏,找到 坚持学习的一万种理由。Timing 业务本身具有潮汐特性,用户访问主要集中在晚间和节假日。受疫情影响,春节期 间峰值流量暴增 4 倍,公司面临较大的运维成本压力。在用户、流量爆发式增长背景下,Timing App 不得不直面以 下四大痛点: (1)系统稳定性差。原有 PHP 单应用架构系统无法做到线性快速扩容,在业务高峰时段,系统问题频繁发生,严 重影响用户体验。(2)产品迭代缓慢。随着业务的高速发展,原有单体架构对于产品的迭代力不从心,没法快速响应研发需求。(3)资源使用浪费。由于业务具有非常强的流量潮夕特征,需要按照业务高峰阶段进行资源保有配置,造成资源 的浪费。 (4)技术成本昂贵。以前的团队除了技术负责人及少数团队新成员外,基本缺乏微服务架构实战经验。想要实现 微服务改造,急需能够快速上手的平台支撑,需要最大限度降低底层 IaaS, 容器以及常用微服务套件的学习 成本。 2、云原生解决方案: 阿里云应用引擎 Serverless(SAE),基于 Serverless 架构,屏蔽了底层 IaaS 运维和 K8s 细节,区别 于 FaaS 形态的 Serverless 产品,用户无需修改编程模型,零代码改造就能直接使用。同时,完美结合 Spring Cloud/Duboo 等微服务架构,提供应用发布、管理和服务治理等应用全生命周期的服务,完美贴合 Timing 的技术 需求:极限弹性伸缩,应用生命周期灵活管理,完美支持主流微服务架构。 下图是方案架构示意图。 3、方案的关键优势: (1)利用弹性伸缩,应对不确定突发流量。提供秒级自动弹性 & 定时弹性能力,帮助应用轻松应对大促峰值流量, 保证 SLA 的同时也节省机器保有成本。多适用于互联网、游戏、在线教育行业。 应用环境随需灵活启停,节约成本。提供了一键启停开发测试环境的能力,即开即用,节省成本,方便运维。 适用于对成本敏感、云上有多套环境但部分环境闲置率较高的企业型客户(不限行业)。 (2)中小企业快速构建云上微服务应用。帮助用户屏蔽底层 IaaS 购买和运维细节、底层 K8s 细节,低门槛部署 微服务应用。适用于初创型 / 上升期的公司(不限行业),业务增长很快,对增长有较高预期,但人员配置 跟不上。 (3)整体技术架构更为清晰,每个服务相互独立且职责明确。加之阿里云应用引擎 Serverless (SAE)加持, 让客户只关注在业务层,做好产品。

优秀的个人博客,低调大师

Dremio案例_Hive数据分析

说明 Dremio-3.3.1支持Hive-2.1.1版本 1.Hive批量导入数据 a).创建表 ## 创建文本数据导入表 CREATE TABLE IF NOT EXISTS database.table_name( agent_id int, accept_time string, signature string, method_type string, success boolean, bad_app boolean, elapse_time bigint, start_time string, end_time string, jsp_weight_time bigint, ejb_weight_time bigint ) ROW FORMAT DELIMITED FIELDS TERMINATED BY ',' LINES TERMINATED BY '\n' STORED AS TEXTFILE; ## 创建Json数据导入表 CREATE TABLE IF NOT EXISTS database.table_name( agent_id int, accept_time string, signature string, method_type string, success boolean, bad_app boolean, elapse_time bigint, start_time string, end_time string, jsp_weight_time bigint, ejb_weight_time bigint ) ROW FORMAT SERDE 'org.apache.hive.hcatalog.data.JsonSerDe' STORED AS TEXTFILE; 注意: 创建Json数据导入表时,会报错;需首先执行 ADD JAR /home/hive/hcatalog/share/hcatalog/hive-hcatalog-core-2.1.1.jar ## 报错信息 query returned non-zero code: 1, cause: create does not exist b).导入数据 ## 导入本地数据 LOAD DATA LOCAL INPATH './hive/entry_index.txt' INTO TABLE database.table_name; ## 导入HDFS数据 LOAD DATA INPATH '/home/hive/entry_index.txt' INTO TABLE database.table_name; c).数据验证 2.配置Hive数据源 3.查询数据 SELECT agent_id,signature,method_type, max(elapse_time) maxElapseTime, min(elapse_time) minElapseTime, avg(elapse_time) avgElapseTime, sum(CASE WHEN success IS TRUE THEN 1 ELSE 0 END) succCount, sum(CASE WHEN bad_app IS TRUE THEN 1 ELSE 0 END) badAppCount, sum(ejb_weight_time) sumEjbWeightTime, sum(jsp_weight_time) sumJspWeightTime FROM entry_indx_txt GROUP BY agent_id,signature,method_type 4.保存查询结果 5.数据分析 a).下载文件 b).选择文件 c).连接数据源 d).结果展示

优秀的个人博客,低调大师

Dremio案例_Elasticserch数据分析

说明 Dremio-3.3.1支持Elasticserch-5.x和6.x;本次使用Elasticserch-6.1.2 1.Elasticserch批量导入数据 ## 导入数据 crul -H 'Content-Type: application/json' -XPOST hostname:9200/dremio/entry_index/_bulk?pretty --data-binary @entry_index.json ## 修改副本数 crul -H 'Content-Type: application/json' -XPUT 'hostname:9200/dremio/_settings' -d '{"index":{"number_of_replicas":"0"}}' 注意:文件数据每行头须有“_id”,否则导入数据报错 {"index":{"_id":"id_num"}} 2.数据验证 3.配置ES数据源 4.查询数据 SELECT agent_id,signature,method_type, max(elapse_time) maxElapseTime, min(elapse_time) minElapseTime, avg(elapse_time) avgElapseTime, sum(CASE WHEN success IS TRUE THEN 1 ELSE 0 END) succCount, sum(CASE WHEN bad_app IS TRUE THEN 1 ELSE 0 END) badAppCount, sum(ejb_weight_time) sumEjbWeightTime, sum(jsp_weight_time) sumJspWeightTime FROM entry_indx GROUP BY agent_id,signature,method_type 5.保存查询结果 6.数据分析 a).下载文件 b).选择文件 c).连接数据源 d).结果展示

优秀的个人博客,低调大师

案例篇-HBase RowKey 设计指南

1.为什么 Rowkey 这么重要 1.1 RowKey 到底是什么 我们常说看一张 HBase 表设计的好不好,就看它的 RowKey 设计的好不好。可见 RowKey 在 HBase 中的地位。那么 RowKey 到底是什么?RowKey 的特点 如下: 类似于 MySQL、Oracle 中的主键,用于标示唯一的行; 完全是由用户指定的一串不重复的字符串; HBase 中的数据永远是根据 Rowkey 的字典排序来排序的。 1.2 RowKey 的作用 读写数据时通过 RowKey 找到对应的 Region; MemStore 中的数据按 RowKey 字典顺序排序; HFile 中的数据按 RowKey 字典顺序排序。 1.3 Rowkey 对查询的影响 如果我们的 RowKey 设计为 uid+phone+name,那么这种设计可以很好的支持以

资源下载

更多资源
Mario

Mario

马里奥是站在游戏界顶峰的超人气多面角色。马里奥靠吃蘑菇成长,特征是大鼻子、头戴帽子、身穿背带裤,还留着胡子。与他的双胞胎兄弟路易基一起,长年担任任天堂的招牌角色。

腾讯云软件源

腾讯云软件源

为解决软件依赖安装时官方源访问速度慢的问题,腾讯云为一些软件搭建了缓存服务。您可以通过使用腾讯云软件源站来提升依赖包的安装速度。为了方便用户自由搭建服务架构,目前腾讯云软件源站支持公网访问和内网访问。

Nacos

Nacos

Nacos /nɑ:kəʊs/ 是 Dynamic Naming and Configuration Service 的首字母简称,一个易于构建 AI Agent 应用的动态服务发现、配置管理和AI智能体管理平台。Nacos 致力于帮助您发现、配置和管理微服务及AI智能体应用。Nacos 提供了一组简单易用的特性集,帮助您快速实现动态服务发现、服务配置、服务元数据、流量管理。Nacos 帮助您更敏捷和容易地构建、交付和管理微服务平台。

Spring

Spring

Spring框架(Spring Framework)是由Rod Johnson于2002年提出的开源Java企业级应用框架,旨在通过使用JavaBean替代传统EJB实现方式降低企业级编程开发的复杂性。该框架基于简单性、可测试性和松耦合性设计理念,提供核心容器、应用上下文、数据访问集成等模块,支持整合Hibernate、Struts等第三方框架,其适用范围不仅限于服务器端开发,绝大多数Java应用均可从中受益。

用户登录
用户注册