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
Hello!
Suppose you are building workflow (order / task / payment) processing system with the following requirements:
Each workflow con...
New
I’m in search of an Elixir library that offers PDF generation capabilities similar to Ruby’s Prawn. While there have been discussions abo...
New
Hey guys,
I’ve got a huge CSV ( around 10 GB ) that needs to be processed hourly
Do you guys have any suggestions what is the best prac...
New
Kia ora,
We have been using elixir-google-api to connect to Google Drive. However, with the updates to Tesla due to CVEs this is now bro...
New
I’ve followed the Phoenix LiveView file upload code here Uploads — Phoenix LiveView v1.0.0-rc.7 and so far everything works just fine wit...
New
I’m using an Umbrella project for a Phoenix application, and I want to have one Ecto Repo and one PostgreSQL database shared by all apps....
New
Hello,
I’m developing a online persistent chat system (what’s app) like using elixir/dynamodb/aws for a mobile app(flutter).
The diffic...
New
Other Trending Topics
Hey, I’m Jesse and I’m the main contributor behind Dexter, a full-featured, lightning-fast Elixir LSP optimized for large codebases. It s...
New
Hobbes is a low-level distributed database for the Elixir programming language.
Hobbes provides a simple, safe, and scalable storage lay...
New
Beam Bots (or just BB for short) is a framework for building fault-tolerant robotics applications in Elixir using familiar OTP patterns. ...
New
ExRatatui lets you cook up rich terminal UIs in Elixir, powered by Rust’s ratatui via Rustler NIFs. Build interactive terminal applicatio...
New
Corex is an accessible, unstyled UI component library for Phoenix that integrates Zag.js state machines using Vanilla JavaScript and Live...
New
Hello everyone. After busy few months I am happy to announce v0.1.0 of Emerge & Solve.
They are GUI (Emerge) and State management (S...
New
Categories:
Sub Categories:
Forums
Popular Tags
- #ecto
- #liveview
- #troubleshooting
- #learning-elixir
- #deployment
- #library
- #erlang
- #testing
- #genserver
- #mix
- #absinthe
- #remote-other
- #otp
- #plug
- #how-to-question
- #macros
- #postgres
- #channels
- #elixirconf
- #exunit
- #discussion
- #code-sync
- #javascript
- #podcasts
- #onsite
- #dialyzer
- #docker
- #authentication
- #umbrella
- #full-time-contract
- #podcasts-by-brainlid
- #ecto-query
- #elixir-ls
- #blog-post
- #ai
- #phoenix_html
- #iex
- #graphql
- #elixirconf-us
- #genstage
- #websockets
- #supervisor
- #advent-of-code
- #distillery
- #processes
- #api
- #forms
- #hex
- #security
- #metaprogramming











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?