Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Hex Core

Wojtek Mach
August 28, 2018
130

Hex Core

Wojtek Mach

August 28, 2018
Tweet

Transcript

  1. What is Hex? • A set of specifications for building

    clients and servers:
 https://github.com/hexpm/specifications •
  2. What is Hex? • A set of specifications for building

    clients and servers:
 https://github.com/hexpm/specifications • A server, like the official one at https://hex.pm •
  3. What is Hex? • A set of specifications for building

    clients and servers:
 https://github.com/hexpm/specifications • A server, like the official one at https://hex.pm • Repo API, e.g.: https://repo.hex.pm •
  4. What is Hex? • A set of specifications for building

    clients and servers:
 https://github.com/hexpm/specifications • A server, like the official one at https://hex.pm • Repo API, e.g.: https://repo.hex.pm • HTTP API, e.g.: https://hex.pm/api •
  5. What is Hex? • A set of specifications for building

    clients and servers:
 https://github.com/hexpm/specifications • A server, like the official one at https://hex.pm • Repo API, e.g.: https://repo.hex.pm • HTTP API, e.g.: https://hex.pm/api • A client •
  6. What is Hex? • A set of specifications for building

    clients and servers:
 https://github.com/hexpm/specifications • A server, like the official one at https://hex.pm • Repo API, e.g.: https://repo.hex.pm • HTTP API, e.g.: https://hex.pm/api • A client • Build tools: Hex for Elixir, rebar3_hex for Erlang etc •
  7. What is Hex? • A set of specifications for building

    clients and servers:
 https://github.com/hexpm/specifications • A server, like the official one at https://hex.pm • Repo API, e.g.: https://repo.hex.pm • HTTP API, e.g.: https://hex.pm/api • A client • Build tools: Hex for Elixir, rebar3_hex for Erlang etc • Other tools: hex-tweet, HexView, Hexagon etc
  8. hex_core • The goal is to be the reference implementation

    of Hex specifications used by Hex clients and servers. •
  9. hex_core • The goal is to be the reference implementation

    of Hex specifications used by Hex clients and servers. • Written in Erlang •
  10. hex_core • The goal is to be the reference implementation

    of Hex specifications used by Hex clients and servers. • Written in Erlang • Available at https://github.com/hexpm/hex_core •
  11. hex_core • The goal is to be the reference implementation

    of Hex specifications used by Hex clients and servers. • Written in Erlang • Available at https://github.com/hexpm/hex_core • Available at https://hex.pm/packages/hex_core
  12. hex_core • The goal is to be the reference implementation

    of Hex specifications used by Hex clients and servers. • Written in Erlang • Available at https://github.com/hexpm/hex_core • Available at https://hex.pm/packages/hex_core
  13. iex> config = :hex_core.default_config() %{ api_url: "https://hex.pm/api", http_adapter: :hex_http_httpc, http_adapter_config:

    %{profile: :default}, http_user_agent_fragment: "(httpc)", repo_public_key: "-----BEGIN PUBLIC KEY...——", repo_url: "https://repo.hex.pm", repo_verify: true }
  14. iex> config = :hex_core.default_config()
 iex> :hex_repo.get_names(config) {:ok, {200, %{ "accept-ranges"

    => "bytes", "age" => "49", "cache-control" => "public, max-age=600", "connection" => "keep-alive", "content-length" => "37816", ... }, %{ packages: [ %{name: "a_message"}, %{name: "aadya"}, %{name: "aatree"}, %{name: "aba"}, %{name: "aba_api"}, %{name: "aba_cli"}, %{name: "aba_model"}, %{name: "abacus"}, %{...}, ... ] }}}
  15. iex> config = :hex_core.default_config() iex> {:ok, {200, _, %{packages: packages}}}

    = :hex_repo.get_names(config) iex> length(packages) 6868
  16. iex> config = :hex_core.default_config() iex> {:ok, {200, _, %{packages: packages}}}

    = :hex_repo.get_names(config) iex> length(packages) 6868 # search for packages matching "riak"
 iex> options = [sort: :downloads] iex> {:ok, {200, _, packages}} = :hex_api_package.search(config, "riak", options) iex> Enum.map(packages, & &1["name"]) ["riak_pb", "riakc", ...]