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

44 lines
1.3 KiB
Crystal

# 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/>.
require "mosquito"
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
require "./worker/*"
module Backend
# Worker module
module Worker
Mosquito.configure do |settings|
settings.redis_url = Backend.config.worker.redis_url
end
end
end