没有问题,kafka 就是主动拉消息的,自己写好异常处理即可。
别用 hibernate ,生命周期挺烦人的。
有时候你写了 save 不更新,但是修改对象属性的时候自动更新了,总之就是反常识,反人类,不要用。
看了一下源码,播放的并不是视频,而是一个类似 GIF 的东西。因为后缀是 mp4 的时候调用的是 remove ,反之将 canvas 传入了一个对象中。
让 AI 反混淆后的源码如下:
```
function getPlayer(element, container, options, autoplay = false, placeholder, startTime) {
return new Promise(resolve => {
let compatibilityLevel;
const canvas = container.querySelector('canvas');
const img = container.querySelector('img');
const video = container.querySelector('video');
if (!this.isSupported || placeholder || (compatibilityLevel = this.app.plgs.fps?.compatLevel) > 0) {
// 如果不支持或需要占位图,则删除 video 和 canvas 元素
canvas.remove();
video?.remove();
resolve(new Player(null));
return;
}
Promise.all([
new Promise(resolve => {
// 检查兼容性
const level = this.app.plgs.fps?.compatLevel;
if (level === undefined) {
resolve(0);
} else if (level > -1) {
resolve(level);
}
// 监听兼容性变化
window.addEventListener(COMPAT_EVENT, ({detail: {level}}) => {
resolve(level);
});
}),
new Promise(resolve => this.onReady(() => resolve()))
]).then(() => {
let src = this.app.isPc() ? element.dataSrcPc : element.dataSrcMo || element.dataSrc;
if (this.app.isPad() && element.dataSrcPad) {
src = element.dataSrcPad;
}
if (!src) {
throw new Error('Video source not specified');
}
if (src.endsWith('mp4')) {
// MP4 视频
if (条件 1 && 条件 2) {
// 不支持,删除元素
canvas.remove();
video?.remove();
resolve(new Player(null));
return;
}
// 删除图片占位符
img.remove();
// 初始化视频
resolve(new Player(video));
video && this.initVideoWithOptions(video, container, src, options);
return;
} else {
// GIF animation
video?.remove();
const player = new GifPlayer(src, this.manager, canvas, options);
if (!autoplay && !startTime) {
// 显示占位图像
img.remove();
} else if (autoplay) {
// 自动播放时删除占位图
player.onFirstFrame(() => {
img.remove();
});
} else if (startTime) {
// 指定 startTime 时删除占位图并 seek 到指定时间
img.remove();
player.seek(startTime);
}
this.players.push(player);
resolve(player);
}
});
});
}
```
你可以这样写
```
package main
import "log"
type OP string
const (
Add OP = "add"
Mul OP = "mul"
)
type step struct {
op OP
value int64
}
func NewMoney(amount int64) *Money {
return &Money{
amount: amount,
}
}
type Money struct {
amount int64
steps []step
}
func (r *Money) Add(v int64) *Money {
r.steps = append(r.steps, step{
op: Add,
value: v,
})
return r
}
func (r *Money) Mul(v int64) *Money {
r.steps = append(r.steps, step{
op: Mul,
value: v,
})
return r
}
func (r *Money) Run() (int64, error) {
for _, step := range r.steps {
switch step.op {
case Add:
r.amount += step.value
case Mul:
r.amount -= step.value
}
}
return r.amount, nil
}
func main() {
val, err := NewMoney(123).Add(456).Mul(123).Run()
if err != nil {
log.Fatal(err)
}
log.Println(val)
}
```
抖音外卖上线很久了,但是身边人从来都没有用过,这是为什么?
不必太在意,很多公司技术都是草台班子,技术不到位,面试的时候只能去网上找一些八股文去问,工作的时候完全用不到。
--add-host=host.docker.internal:host-gateway
搞错了,是这个命令
docker run --add-host=host.docker.internal:宿主机 IP
你在容器里面访问 host.docker.internal 即可。