Organizations

Pinned

  1. 源于这篇文章: 一行Golang代码引发的血案——全网最详细分析2020年3月Let’s Encrypt证书吊销事故 对于循环变量的理解 type element struct { ele string } func getList() []*string { originMap := []element{ {"A"}, {"B"}, {"C"}, } arr := []*string{} for _, v := range originMap { arr = append(arr, &v.ele) } return arr } func TestWrongReference(t *testing.T) { arr := getList() assert.Equal(t, "C", *arr[0]) assert.Equal(t, "C", *arr[1]) assert.Equal(t, "C", *arr[2]) } 之类可以这么理解: 变量的声明是在循环外面的,所以一直是一样的 变量的内容是从slice里copy出来的,所以每次loop会变 存在arr里的是这个变量内部的地址 ./wrongreference.go:15:3: moved to heap: v .
    Updated March 13, 2020
  2. 通过配置文件进行连接的方式: docker run -it -v $HOME/.clickhouse-client/oldch.xml:/root/.clickhouse-client/config.xml yandex/clickhouse-client 当然也可以直接运行这个client的命令: docker run -it yandex/clickhouse-client 如果不要compression,可以这么传: docker run -it yandex/clickhouse-client --compression=0
    Updated February 29, 2020
  3. 主流程 main@main.rs topology::start_validated@topology/mod.rs running_topology.spawn_all@topology/mod.rs 这里不仅是新建,也负责diff and adjust spawn_source spawn_transform spawn_sink 概念树 拓扑逻辑 let mut running_topology = RunningTopology { inputs: HashMap::new(), outputs: HashMap::new(), config: Config::empty(), shutdown_triggers: HashMap::new(), source_tasks: HashMap::new(), tasks: HashMap::new(), abort_tx, }; 可以看到vector里的拓扑逻辑较为简单, 核心是in/out
    Updated February 22, 2020
  4. sagas背景 Sagas are Long Lived Transactions Sagas are a lot of small transactions Sagas are a Failure Management Pattern 相关论文 redux-sagas是专门用来处理副作用的,这样redux及react的其他部分就可以保持pure的状态 栗子: import { delay } from 'redux-saga' import { put, takeEvery } from 'redux-saga/effects' // ... // Our worker Saga: 将执行异步的 increment 任务 export function* incrementAsync() { yield delay(1000) yield put({ type: 'INCREMENT' }) } // Our watcher Saga: 在每个 INCREMENT_ASYNC action spawn 一个新的 incrementAsync 任务 export function* watchIncrementAsync() { yield takeEvery('INCREMENT_ASYNC', incrementAsync) } sagas使用generator而不是await来等待异步函数,
    Updated February 17, 2020
  5. useEffect useEffect( () => { const subscription = props.source.subscribe(); return () => { subscription.unsubscribe(); }; }, [props.source], ); 主要函数同componentDidMount componentDidUpdate, 返回的函数同componentDidUmount, 由传入的source来决定是否触发 useState const [state, setState] = useState(initialState); 按位置挂在状态,所以外层不要有分支,不要有循环,不然可能挂载出错 内容改变后会触发render useRef 同useState,但不触发render function TextInputWithFocusButton() { const inputEl = useRef(null); const onButtonClick = () => { // `current` 指向已挂载到 DOM 上的文本输入元素 inputEl.current.focus(); }; return ( <> <input ref={inputEl} type="text" /> <button onClick={onButtonClick}>Focus the input</button> </> ); } 通常也被用来这样引用Dom树 另外同createRef不同的点是,不会每次render都创建新的 useContext 当前的 context 值由上层组件中距离当前组件最近的 <MyContext.
    Updated February 15, 2020
  6. web: image: nginx volumes: - ./www:/usr/share/nginx/html:ro ports: - 80:80
    Updated February 14, 2020