teamon
October 19, 2017, 9:14am
1
I’ve been trying to understand compile-time dependencies between files/modules.
I know the basics, like when module is references inside macro it will be linked as compile-time dependency etc.
However, I can’t figure out the dependency graph for tesla
Here is the output of mix xref graph
:
⌘ ~/code/tesla (master) λ elixir --version
Erlang/OTP 20 [erts-9.1] [source] [64-bit] [smp:4:4] [ds:4:4:10] [async-threads:10] [hipe] [kernel-poll:false]
Elixir 1.6.0-dev (5b9a5ff) (compiled with OTP 20)
⌘ ~/code/tesla (master) λ mix xref graph
lib/tesla.ex
├── lib/tesla/adapter/hackney.ex (compile)
│ ├── lib/tesla/multipart.ex (compile)
│ └── lib/tesla.ex
├── lib/tesla/adapter/httpc.ex (compile)
│ ├── lib/tesla/adapter/shared.ex (compile)
│ ├── lib/tesla/multipart.ex (compile)
│ └── lib/tesla.ex
├── lib/tesla/adapter/ibrowse.ex (compile)
│ ├── lib/tesla/adapter/shared.ex (compile)
│ ├── lib/tesla/multipart.ex (compile)
│ └── lib/tesla.ex
├── lib/tesla/middleware/core.ex (compile)
│ ├── lib/tesla.ex (compile)
├── lib/tesla/middleware/basic_auth.ex (compile)
│ ├── lib/tesla.ex (compile)
├── lib/tesla/middleware/compression.ex (compile)
│ ├── lib/tesla.ex (compile)
├── lib/tesla/middleware/logger.ex (compile)
│ ├── lib/tesla.ex (compile)
├── lib/tesla/middleware/decode_rels.ex (compile)
│ ├── lib/tesla.ex (compile)
├── lib/tesla/middleware/digest_auth.ex (compile)
│ ├── lib/tesla.ex (compile)
├── lib/tesla/middleware/follow_redirects.ex (compile)
│ ├── lib/tesla.ex (compile)
├── lib/tesla/middleware/form_urlencoded.ex (compile)
│ ├── lib/tesla.ex (compile)
│ ├── lib/tesla/multipart.ex (compile)
├── lib/tesla/middleware/fuse.ex (compile)
│ ├── lib/tesla.ex (compile)
lib/tesla/adapter/hackney.ex
lib/tesla/adapter/httpc.ex
lib/tesla/adapter/ibrowse.ex
lib/tesla/adapter/shared.ex
lib/tesla/middleware/basic_auth.ex
lib/tesla/middleware/compression.ex
lib/tesla/middleware/core.ex
lib/tesla/middleware/decode_rels.ex
lib/tesla/middleware/digest_auth.ex
lib/tesla/middleware/follow_redirects.ex
lib/tesla/middleware/form_urlencoded.ex
lib/tesla/middleware/fuse.ex
lib/tesla/middleware/json.ex
├── lib/tesla.ex (compile)
lib/tesla/middleware/logger.ex
lib/tesla/middleware/method_override.ex
├── lib/tesla.ex (compile)
lib/tesla/middleware/retry.ex
├── lib/tesla.ex (compile)
lib/tesla/middleware/timeout.ex
├── lib/tesla.ex (compile)
lib/tesla/middleware/tuples.ex
├── lib/tesla.ex (compile)
lib/tesla/mock.ex
└── lib/tesla.ex (compile)
lib/tesla/multipart.ex
What I do not get about this, is why for example lib/tesla.ex
has a dependency on lib/tesla/middleware/form_urlencoded.ex
but not on lib/tesla/middleware/json.ex
?
Eiji
October 19, 2017, 10:45am
2
@teamon : I don’t read all sources, but you could look at compile-time &Tesla.alias/1
calls. Maybe other module use this and therefore uses only one of aliased module that you asked about.
teamon
October 19, 2017, 11:07am
3
Not in middlewares
⌘ ~/code/tesla (master) λ grep -R alias lib 130
lib/tesla/adapter/hackney.ex: alias Tesla.Multipart
lib/tesla/adapter/httpc.ex: alias Tesla.Multipart
lib/tesla/adapter/ibrowse.ex: alias Tesla.Multipart
lib/tesla.ex: middleware = Tesla.alias(middleware)
lib/tesla.ex: adapter = Tesla.alias(adapter)
lib/tesla.ex: @aliases [
lib/tesla.ex: def alias(key) when is_atom(key), do: Keyword.get(@aliases, key, key)
lib/tesla.ex: def alias(key), do: key
lib/tesla.ex: Application.get_env(:tesla, module, [])[:adapter] |> Tesla.alias
lib/tesla.ex: Application.get_env(:tesla, :adapter, :httpc) |> Tesla.alias
It is a bug in how we are printing the data (not in how are gathering it). I have a fix in place but first I need a test.
1 Like
teamon
October 19, 2017, 11:52am
5
Whoo
Does this apply to dot version too?
Here too some of middleware have only one compile time dependency and some have two.
Yup. Both should be fixed in master though.
teamon
October 19, 2017, 12:12pm
7
Indeed it is:
⌘ ~/code/tesla (master) λ elixir --version
Erlang/OTP 20 [erts-9.1] [source] [64-bit] [smp:4:4] [ds:4:4:10] [async-threads:10] [hipe] [kernel-poll:false]
Elixir 1.6.0-dev (e95f564) (compiled with OTP 19)
⌘ ~/code/tesla (master) λ mix xref graph
lib/tesla.ex
├── lib/tesla/adapter/hackney.ex (compile)
│ ├── lib/tesla.ex
│ └── lib/tesla/multipart.ex (compile)
├── lib/tesla/adapter/httpc.ex (compile)
│ ├── lib/tesla.ex
│ ├── lib/tesla/adapter/shared.ex (compile)
│ └── lib/tesla/multipart.ex (compile)
├── lib/tesla/adapter/ibrowse.ex (compile)
│ ├── lib/tesla.ex
│ ├── lib/tesla/adapter/shared.ex (compile)
│ └── lib/tesla/multipart.ex (compile)
├── lib/tesla/middleware/basic_auth.ex (compile)
│ └── lib/tesla.ex (compile)
├── lib/tesla/middleware/compression.ex (compile)
│ ├── lib/tesla.ex (compile)
│ └── lib/tesla/middleware/core.ex
│ └── lib/tesla.ex (compile)
├── lib/tesla/middleware/core.ex (compile)
├── lib/tesla/middleware/decode_rels.ex (compile)
│ └── lib/tesla.ex (compile)
├── lib/tesla/middleware/digest_auth.ex (compile)
│ └── lib/tesla.ex (compile)
├── lib/tesla/middleware/follow_redirects.ex (compile)
│ └── lib/tesla.ex (compile)
├── lib/tesla/middleware/form_urlencoded.ex (compile)
│ ├── lib/tesla.ex (compile)
│ ├── lib/tesla/middleware/core.ex
│ └── lib/tesla/multipart.ex (compile)
├── lib/tesla/middleware/fuse.ex (compile)
│ └── lib/tesla.ex (compile)
├── lib/tesla/middleware/json.ex (compile)
│ ├── lib/tesla.ex (compile)
│ ├── lib/tesla/middleware/core.ex
│ └── lib/tesla/multipart.ex (compile)
├── lib/tesla/middleware/logger.ex (compile)
│ ├── lib/tesla.ex (compile)
│ └── lib/tesla/multipart.ex (compile)
├── lib/tesla/middleware/method_override.ex (compile)
│ ├── lib/tesla.ex (compile)
│ └── lib/tesla/middleware/core.ex
├── lib/tesla/middleware/retry.ex (compile)
│ └── lib/tesla.ex (compile)
├── lib/tesla/middleware/timeout.ex (compile)
│ └── lib/tesla.ex (compile)
├── lib/tesla/middleware/tuples.ex (compile)
│ └── lib/tesla.ex (compile)
└── lib/tesla/mock.ex (compile)
└── lib/tesla.ex (compile)
lib/tesla/adapter/hackney.ex
lib/tesla/adapter/httpc.ex
lib/tesla/adapter/ibrowse.ex
lib/tesla/adapter/shared.ex
lib/tesla/middleware/basic_auth.ex
lib/tesla/middleware/compression.ex
lib/tesla/middleware/core.ex
lib/tesla/middleware/decode_rels.ex
lib/tesla/middleware/digest_auth.ex
lib/tesla/middleware/follow_redirects.ex
lib/tesla/middleware/form_urlencoded.ex
lib/tesla/middleware/fuse.ex
lib/tesla/middleware/json.ex
lib/tesla/middleware/logger.ex
lib/tesla/middleware/method_override.ex
lib/tesla/middleware/retry.ex
lib/tesla/middleware/timeout.ex
lib/tesla/middleware/tuples.ex
lib/tesla/mock.ex
lib/tesla/multipart.ex
@josevalim You are impossible, thank you!
1 Like