elixir

最终,我们放弃了GO,迁移至Rust,特性使然

耗尽温柔 提交于 2020-03-24 08:36:33
3 月,跳不动了?>>> 云栖号: https://yqh.aliyun.com 第一手的上云资讯,不同行业精选的上云企业案例库,基于众多成功案例萃取而成的最佳实践,助力您上云决策! 在各个领域,Rust 都已经成为一流的语言。在 Discord,我们看到了 Rust 在客户端和服务端的成功。举例来说,我们在客户端使用它实现了 Go Live 的视频编码管道,在服务端,它则被用于 Elixir NIFs。最近,我们通过将服务的实现从 Go 切换到 Rust,极大地提升了该服务的性能。本文阐述了重新实现服务为何是有价值的、该过程是如何实现的以及由此带来的性能提升。 Read States 服务 Discord 是一家以产品为中心的公司,所以我们先介绍一下产品的背景信息。我们从 Go 切换到 Rust 的服务叫做“Read States”服务。它的唯一目的是跟踪用户阅读了哪些频道和信息。每当用户连接 Discord 的时候,每当消息发送的时候,每当消息被读取的时候,都会访问 Read States。简而言之,Read States 处于最关键的位置。我们希望能够保证 Discord 始终让人感觉快捷无比,所以必须要确保 Read States 是非常快速的。 在 Go 的实现中,Read States 无法支持产品的需求。在大多数情况下,它都是很快速的

Elixir Swarm浅析

送分小仙女□ 提交于 2020-03-23 16:09:36
3 月,跳不动了?>>> Elixir是一门很有意思的语言,它的社区把很多的关注重点放在了解决集群化带来的挑战上。 libcluster 和 swarm 就是为此诞生的两个库。但是由于这门语言还很年轻,很多文档还很不成熟(Swarm的文档就是这样),所以有很多时候你要自己亲手做实验才能明白其中的门道。今天我们就来聊聊Swarm这个库。 前言 也许你早就听说过CAP定律。简单说,就是“一致性( C onsistency)、可用性( A vailability)、分区容错性( P artition tolerance)三者在一个分布式数据容器里最多只能要两个”。 Elixir Swarm给了我们选择CP(一致性+分区容错性)或AP(可用性+分区容错性)的自由。 Elixir Swarm基础 我们就做一个分布式计数器,它只支持两个操作:获取当前值(value)和+1(increment)。首先创建一个项目: $ mix new --sup counter 然后创建一个worker模块。我这里用GenServer而不用Agent是因为接下来会往里加Elixir Swarm生命周期的钩子,如果用Agent不方便。 defmodule Counter.Worker do use GenServer def start_link(_) do GenServer.start_link(_

Ecto or Elixir datatype that maps to MySql BIGINT

天大地大妈咪最大 提交于 2020-03-22 06:55:21
问题 I'm new to Elixir and Phoenix (6 months learning), I have a situation where I want to assign an Ecto model's field (not primary key or table ID) to BIGINT in MySql. I realize when you create an Ecto model, the ID of that model in MySql table would automatically mapped to BIGINT after migration. After checking this site, I tried to create an Ecto model's field to :integer or :id in both model and its corresponding migration script but it always gives me INT datatype in MySql. Anybody knows

芝加哥交易公司.

我怕爱的太早我们不能终老 提交于 2020-03-13 16:39:27
https://www.builtinchicago.org/2019/06/07/chicago-trading-firms Software Engineer, Risk DRW | CHICAGO DRW is a technology-driven, diversified principal trading firm. We trade our own capital at our own risk, across a broad range of asset classes, instruments and strategies, in financial markets around the world. As the markets have evolved over the past 25 years, so has DRW – maximizing opportunities to include real estate, cryptoassets and venture capital. With over 1,000 employees at our Chicago headquarters and offices around the world, we work together to solve complex problems, challenge

Elixir: Convert list of bits to binary

社会主义新天地 提交于 2020-03-03 12:15:42
问题 I have a list of integers representing bits; e.g. [1,0,0,1,1,0,0,1,0,0,0,1,1,1,0,0] and I would like to convert it into a binary i.e. <<153, 28>> , I know that the length of the list will always be a multiple of 8. I have looked at the Elixir documentation, but I have not been able to find any help (I have looked for the exact function but also for a function for appending a bit to a binary). I have written a function which solves the problem (below) but I hoped there was a better way as I

CentOS 7 安装Elixir

匆匆过客 提交于 2020-02-28 20:36:01
1、 安装Elixir之前必须要先安装Erlang 参考1: 【CentOS 7 系统安装 Erlang/OTP 22.0】 进行安装 参考2: 【Centos 用Kerl安装及管理Erlang】 进行安装 2、安装Elixir $ git clone https://github.com/elixir-lang/elixir.git $ cd elixir $ make clean test 输出示例: [root@SummerGao elixir]# make clean test rm -rf ebin rm -rf lib/*/ebin rm -rf lib/elixir/src/elixir_parser.erl make[1]: Entering directory `/home/summergao/elixir' rm -rf lib/*/_build/ rm -rf lib/*/tmp/ rm -rf lib/elixir/test/ebin/ rm -rf lib/mix/test/fixtures/deps_on_git_repo/ rm -rf lib/mix/test/fixtures/git_rebar/ rm -rf lib/mix/test/fixtures/git_repo/ rm -rf lib/mix/test/fixtures/git

How to enforce JSON encoding for Phoenix Request?

孤者浪人 提交于 2020-02-27 23:42:27
问题 There's some API made with Phoenix, the API works with JSON. But, when you test it and sent JSON with curl it fail because Phoenix doesn't parse the request as JSON. You need to explicitly add application/json header to curl . I'd like to make it more robust and tell Phoenix to always parse all requests as JSON. Is there a way to force Phoenix to always treat requests as JSON and parse it as JSON? UPDATE I tried to use plug to set request headers as @AbM suggested, with the following code in

Elixir - Nested JSON parsing to structs

江枫思渺然 提交于 2020-02-18 09:53:55
问题 Disclaimer: I've checked the question here and it does not answer mine. I am trying to come up with a way for nested struct parsing of JSONs. Example: {"name": "blah blah", "address": {"street": "smthing"}} I want to reach this result: %User{name: "blah blah", address: %Address{street: "smthing"}} Because then it would be easier to plug validation (using Vex for exapmle). I know that Poison supports the "as struct" option but it does not provide nesting. The above would be parsed: %User{name:

Elixir - Nested JSON parsing to structs

雨燕双飞 提交于 2020-02-18 09:50:46
问题 Disclaimer: I've checked the question here and it does not answer mine. I am trying to come up with a way for nested struct parsing of JSONs. Example: {"name": "blah blah", "address": {"street": "smthing"}} I want to reach this result: %User{name: "blah blah", address: %Address{street: "smthing"}} Because then it would be easier to plug validation (using Vex for exapmle). I know that Poison supports the "as struct" option but it does not provide nesting. The above would be parsed: %User{name:

laravel+vue结合使用

泄露秘密 提交于 2020-02-10 23:08:35
SegmentFault 首页 问答 专栏 讲堂 圈子 发现 搜索 立即登录 免费注册 在 SegmentFault,学习技能、解决问题 每个月,我们帮助 1000 万的开发者解决各种各样的技术问题。并助力他们在技术能力、职业生涯、影响力上获得提升。 免费注册 立即登录 Laravel 中使用 Vue 组件化开发(配置) javascript php jcc 2016年08月18日发布 赞 | 8 收藏 | 83 14.7k 次浏览 更多请关注 Laravel.so 、 PIGJIAN BLOG 现今前端组件化开发、 MVVM 模式,给开发带来了很多的便利,可读性、可维护性更高。然而自 Laravel 5.3 开始, VueJS 成为框架默认的标配。 本文基于 Laravel 5.1 LTS 版本引入 Vue 2.0 进行配置。 我已在 Github 配置好, Laravel 5.1 和 Laravel 5.2 均有, Clone 下来后按照 README 安装依赖后即可用: https://github.com/jcc/vue-laravel-example 步骤一:配置 package.json 1. 在根目录下修改 package.json , 可在 devDependencies 下配置你所需的所有依赖。我的配置如下: { "private": true, "scripts