chan11347
iex(1)> {:ok, todo_system_pid} = Todo.System.start_link()
Starting database worker 1
Starting database worker 2
Starting database worker 3
Starting to-do cache
{:ok, #PID<0.141.0>}
iex(2)> {:ok, todo_system_pid: todo_system_pid}
{:ok, [todo_system_pid: #PID<0.141.0>]}
iex(3)> abc = Todo.Cache.server_process("abc")
Starting to-do server for abc
#PID<0.151.0>
iex(4)> Todo.Server.add_entry(abc, %{date: ~D[2020-05-19], time: ~T[00:00:00], title: "Shopping"})
:ok
iex(5)> Todo.Server.add_entry(abc, %{date: ~D[2020-05-19], time: ~T[00:01:00], title: "Hacking"})
:ok
iex(6)> Todo.Server.add_entry(abc, %{date: ~D[2020-05-20], time: ~T[00:00:00], title: "Swimming"})
:ok
iex(7)> Todo.Server.entries(abc, ~D[2020-05-19], ~T[00:00:00])
[%{date: ~D[2020-05-19], id: 22, time: ~T[00:00:00], title: "Shopping"}]
iex(8)> Todo.Server.date_check(abc, ~D[2020-05-20])
[
%{date: ~D[2020-05-20], id: 1, time: ~T[16:52:00], title: "Shopping"},
%{date: ~D[2020-05-20], id: 2, time: ~T[16:53:00], title: "Playing"},
%{date: ~D[2020-05-20], id: 3, time: ~T[16:53:00], title: "swimming"},
%{date: ~D[2020-05-20], id: 4, time: ~T[16:52:00], title: "Shopping"},
%{date: ~D[2020-05-20], id: 5, time: ~T[16:53:00], title: "Playing"},
%{date: ~D[2020-05-20], id: 6, time: ~T[16:53:00], title: "swimming"},
%{date: ~D[2020-05-20], id: 7, time: ~T[16:52:00], title: "Shopping"},
%{date: ~D[2020-05-20], id: 8, time: ~T[16:53:00], title: "Playing"},
%{date: ~D[2020-05-20], id: 9, time: ~T[16:52:00], title: "Shopping"},
%{date: ~D[2020-05-20], id: 10, time: ~T[16:53:00], title: "Playing"},
%{date: ~D[2020-05-20], id: 11, time: ~T[16:53:00], title: "swimming"},
%{date: ~D[2020-05-20], id: 12, time: ~T[16:52:00], title: "Shopping"},
%{date: ~D[2020-05-20], id: 13, time: ~T[16:53:00], title: "Playing"},
%{date: ~D[2020-05-20], id: 14, time: ~T[16:53:00], title: "swimming"},
%{date: ~D[2020-05-20], id: 15, time: ~T[16:53:00], title: "Playing"},
%{date: ~D[2020-05-20], id: 16, time: ~T[16:52:00], title: "Shopping"},
%{date: ~D[2020-05-20], id: 17, time: ~T[16:53:00], title: "Playing"},
%{date: ~D[2020-05-20], id: 18, time: ~T[16:53:00], title: "swimming"},
%{date: ~D[2020-05-20], id: 19, time: ~T[16:52:00], title: "Shopping"},
%{date: ~D[2020-05-20], id: 20, time: ~T[16:53:00], title: "Playing"},
%{date: ~D[2020-05-20], id: 21, time: ~T[16:53:00], title: "swimming"},
%{date: ~D[2020-05-20], id: 24, time: ~T[00:00:00], title: "Swimming"}
]
iex(9)> Todo.Server.time_check(abc, ~T[00:00:00])
[
%{date: ~D[2020-05-19], id: 22, time: ~T[00:00:00], title: "Shopping"},
%{date: ~D[2020-05-20], id: 24, time: ~T[00:00:00], title: "Swimming"}
]
iex(10)> Todo.Server.delete_entry(abc, 24)
:ok
iex(11)> Todo.Server.time_check(abc, ~T[00:00:00])
18:32:46.287 [error] GenServer {Todo.ProcessRegistry, {Todo.Server, "abc"}} terminating
** (ArgumentError) argument error
:erlang.apply("abc", :entries, [])
(todo) lib/todo/list.ex:30: Todo.List.time_check/2
(todo) lib/todo/server.ex:58: Todo.Server.handle_call/3
(stdlib) gen_server.erl:661: :gen_server.try_handle_call/4
(stdlib) gen_server.erl:690: :gen_server.handle_msg/6
(stdlib) proc_lib.erl:249: :proc_lib.init_p_do_apply/3
Last message (from #PID<0.139.0>): {:time_check, ~T[00:00:00]}
State: {%Todo.List{auto_id: 25, entries: %{1 => %{date: ~D[2020-05-20], id: 1, time: ~T[16:52:00], title: "Shopping"}, 2 => %{date: ~D[2020-05-20], id: 2, time: ~T[16:53:00], title: "Playing"}, 3 => %{date: ~D[2020-05-20], id: 3, time: ~T[16:53:00], title: "swimming"}, 4 => %{date: ~D[2020-05-20], id: 4, time: ~T[16:52:00], title: "Shopping"}, 5 => %{date: ~D[2020-05-20], id: 5, time: ~T[16:53:00], title: "Playing"}, 6 => %{date: ~D[2020-05-20], id: 6, time: ~T[16:53:00], title: "swimming"}, 7 => %{date: ~D[2020-05-20], id: 7, time: ~T[16:52:00], title: "Shopping"}, 8 => %{date: ~D[2020-05-20], id: 8, time: ~T[16:53:00], title: "Playing"}, 9 => %{date: ~D[2020-05-20], id: 9, time: ~T[16:52:00], title: "Shopping"}, 10 => %{date: ~D[2020-05-20], id: 10, time: ~T[16:53:00], title: "Playing"}, 11 => %{date: ~D[2020-05-20], id: 11, time: ~T[16:53:00], title: "swimming"}, 12 => %{date: ~D[2020-05-20], id: 12, time: ~T[16:52:00], title: "Shopping"}, 13 => %{date: ~D[2020-05-20], id: 13, time: ~T[16:53:00], title: "Playing"}, 14 => %{date: ~D[2020-05-20], id: 14, time: ~T[16:53:00], title: "swimming"}, 15 => %{date: ~D[2020-05-20], id: 15, time: ~T[16:53:00], title: "Playing"}, 16 => %{date: ~D[2020-05-20], id: 16, time: ~T[16:52:00], title: "Shopping"}, 17 => %{date: ~D[2020-05-20], id: 17, time: ~T[16:53:00], title: "Playing"}, 18 => %{date: ~D[2020-05-20], id: 18, time: ~T[16:53:00], title: "swimming"}, 19 => %{date: ~D[2020-05-20], id: 19, time: ~T[16:52:00], title: "Shopping"}, 20 => %{date: ~D[2020-05-20], id: 20, time: ~T[16:53:00], title: "Playing"}, 21 => %{date: ~D[2020-05-20], id: 21, time: ~T[16:53:00], title: "swimming"}, 22 => %{date: ~D[2020-05-19], id: 22, time: ~T[00:00:00], title: "Shopping"}, 23 => %{date: ~D[2020-05-19], id: 23, time: ~T[00:01:00], title: "Hacking"}}}, "abc"}
Client #PID<0.139.0> is alive
(stdlib) gen.erl:169: :gen.do_call/4
(elixir) lib/gen_server.ex:1006: GenServer.call/3
(stdlib) erl_eval.erl:680: :erl_eval.do_apply/6
(elixir) src/elixir.erl:275: :elixir.eval_forms/4
(iex) lib/iex/evaluator.ex:257: IEx.Evaluator.handle_eval/5
(iex) lib/iex/evaluator.ex:237: IEx.Evaluator.do_eval/3
(iex) lib/iex/evaluator.ex:215: IEx.Evaluator.eval/3
(iex) lib/iex/evaluator.ex:103: IEx.Evaluator.loop/1
** (exit) exited in: GenServer.call(#PID<0.151.0>, {:time_check, ~T[00:00:00]}, 5000)
** (EXIT) an exception was raised:
** (ArgumentError) argument error
:erlang.apply("abc", :entries, [])
(todo) lib/todo/list.ex:30: Todo.List.time_check/2
(todo) lib/todo/server.ex:58: Todo.Server.handle_call/3
(stdlib) gen_server.erl:661: :gen_server.try_handle_call/4
(stdlib) gen_server.erl:690: :gen_server.handle_msg/6
(stdlib) proc_lib.erl:249: :proc_lib.init_p_do_apply/3
(elixir) lib/gen_server.ex:1009: GenServer.call/3
iex(11)>
so this is what i do, i was trying to use this function to delete the entry but after i check my list again, there is an error comming out, this is my code for delete_entry
list.ex
def delete_entry(todo_list, entry_id) do
new_entries = Map.delete(todo_list.entries, entry_id)
%Todo.List{todo_list | entries: new_entries}
end
server.ex
def delete_entry(todo_server, entry_id) do
GenServer.cast(todo_server, {:delete_entry, entry_id})
end
@impl GenServer
def handle_cast({:delete_entry, entry_id}, {name, todo_list}) do
{:noreply, {Todo.List.delete_entry(todo_list, entry_id), name}}
end
Trending in Questions
Hi all,
I’m working on a Phoenix project where I need to make external HTTP requests and I’m trying to choose between Req and HTTPoison....
New
I’m very new to Elixir, so sorry if this is a silly question:
I am wondering what happens to the mailbox of a process when the machine i...
New
How do I tell Hologram not to escape HTML when substituting into templates?
{Textile.render(@product.long_description)}
escapes the HTM...
New
Background
When trying to execute mix release on a Windows 11 machine for a Phoenix project I get the following error:
* assembling mark...
New
I’d like to create a file with 600 permissions (rw-------), but there’s a race condition if I create it and then change the permissions. ...
New
Is there a way to import record definitions in the iex shell for pretty printing (similar to the rr command in the erl shell)? This woul...
New
When I use Mix.install with a git dependency, using git@github.com:... how do I change the SSH identity used?
I’ve got two Github accoun...
New
Other Trending Topics
Hey there,
I haven’t seen a list of useful Elixir specific skills for the popular AI tools yet so I’m starting one here with my first.
...
New
Hi everyone :waving_hand:
I wanted to share something I’ve been building — NowBlind, a random chat app designed to help people discover ...
New
I fully migrated to my own harness from Anthropic/Gemini and I think it’s time to share it. Welcome DSH, the DeepSeek Harness, fully writ...
New
(I just needed to vent somewhere and LinkedIn is full of hope, or hype, I’m not sure which exactly)
AI dream has many faces, but general...
New
Localize is the next generation localisation library for Elixir. Think of it as ex_cldr version 3.0. The first version will be released ...
New
Beam Bots (or just BB for short) is a framework for building fault-tolerant robotics applications in Elixir using familiar OTP patterns. ...
New
Categories:
Sub Categories:
Forums
Popular Tags
- #ecto
- #liveview
- #troubleshooting
- #learning-elixir
- #library
- #deployment
- #erlang
- #testing
- #genserver
- #mix
- #absinthe
- #remote-other
- #otp
- #plug
- #how-to-question
- #macros
- #postgres
- #elixirconf
- #channels
- #exunit
- #code-sync
- #discussion
- #podcasts
- #javascript
- #onsite
- #dialyzer
- #docker
- #authentication
- #ai
- #umbrella
- #elixirconf-us
- #full-time-contract
- #podcasts-by-brainlid
- #blog-post
- #ecto-query
- #elixir-ls
- #phoenix_html
- #iex
- #graphql
- #genstage
- #websockets
- #supervisor
- #advent-of-code
- #distillery
- #elixirconf-eu
- #processes
- #security
- #api
- #forms
- #performance










Showing Posts 1 to 10- Show Best Posts
- Show All (oldest first)
- Show All (newest first)
kokolegorille
Here You are switching position in the tuple…
That is where You should find the error.
chan11347
sorry but if i dont understand what switching position in the tuple meaning are you saying
changed to
?
kokolegorille
The state of your genserver is a tuple…
Here You put
But You return…
You are switching the information in the tuple, maybe this is what You want?
What is the initial state of the Genserver?
chan11347
i want to remove the information in the list
which i try to delete it by the id
if you talk about the init
abc = Todo.Cache.server_process(“abc”)
Starting to-do server for abc
pid<0.151.0>
kokolegorille
The error is in this file, at line 30…
And You should be careful what You return, because You switch the list and the name in the tuple.
chan11347
i did try change it to todo_list.time_check
but it just crash it at the first time
and if i change to this
will it better? since i try to copy the add_entry format to do it
kokolegorille
Try to inspect the todo_list. My guess is You don’t provide the right parameter to the function.
chan11347
Let say i step by step
above all return :ok
Todo.Server.entries(a, ~D[2020-05-19], ~T[16:52:00])kokolegorille
Let say You correct this wrong code…
Let say You put an inspect, and tell us what You got…
chan11347
So it isn’t the input value is on the part of the Todo.List.delete_entry(todo_list, entry_id) ?
and why when the name should put it into the front make a big difference?