mentorenwahl/docker/backend/src/backend/worker.cr

44 lines
1.3 KiB
Crystal
Raw Normal View History

2022-02-10 07:43:47 +00:00
# Mentorenwahl: A fullstack application for assigning mentors to students based on their whishes.
# Copyright (C) 2022 Dominic Grimm
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.
2022-01-23 08:12:57 +00:00
require "mosquito"
2022-01-28 17:30:20 +00:00
module Mosquito::Serializers::Granite
macro serialize_granite_model(klass)
{% method_suffix = klass.resolve.stringify.underscore.gsub(/::/, "__").id %}
def serialize_{{ method_suffix }}(model : {{ klass.id }}) : String
model.id.to_s
end
def deserialize_{{ method_suffix }}(raw : String) : {{ klass.id }}
id = raw.to_i
{{ klass.id }}.find(id).not_nil!
end
end
end
2022-01-23 08:12:57 +00:00
require "./worker/*"
module Backend
2022-02-07 19:58:24 +00:00
# Worker module
2022-01-23 08:12:57 +00:00
module Worker
Mosquito.configure do |settings|
2022-02-03 16:28:32 +00:00
settings.redis_url = Backend.config.worker.redis_url
2022-01-23 08:12:57 +00:00
end
end
end