{"id":15713648,"url":"https://github.com/steffanperry/minetrain","last_synced_at":"2026-04-29T18:32:44.501Z","repository":{"id":233915142,"uuid":"580986294","full_name":"SteffanPerry/MineTrain","owner":"SteffanPerry","description":"AWS Lambda runtime for Crystal Lang","archived":false,"fork":false,"pushed_at":"2022-12-28T15:12:25.000Z","size":6545,"stargazers_count":3,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-30T18:47:12.277Z","etag":null,"topics":["aws","aws-lambda","crystal","crystal-lang","crystal-language"],"latest_commit_sha":null,"homepage":"","language":"Crystal","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/SteffanPerry.png","metadata":{"files":{"readme":"Readme.md","changelog":null,"contributing":null,"funding":null,"license":"License","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null}},"created_at":"2022-12-22T01:00:53.000Z","updated_at":"2023-01-09T19:12:45.000Z","dependencies_parsed_at":"2024-04-17T17:34:36.987Z","dependency_job_id":"c8c88e2e-80d6-42d5-ab82-82bad0cf48ed","html_url":"https://github.com/SteffanPerry/MineTrain","commit_stats":null,"previous_names":["steffanperry/minetrain"],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SteffanPerry%2FMineTrain","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SteffanPerry%2FMineTrain/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SteffanPerry%2FMineTrain/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SteffanPerry%2FMineTrain/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/SteffanPerry","download_url":"https://codeload.github.com/SteffanPerry/MineTrain/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246365640,"owners_count":20765546,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["aws","aws-lambda","crystal","crystal-lang","crystal-language"],"created_at":"2024-10-03T21:32:38.090Z","updated_at":"2026-04-29T18:32:44.459Z","avatar_url":"https://github.com/SteffanPerry.png","language":"Crystal","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Warning\nThis project is still in very early development stages, but should be complete enough to use in production. that being said, use this at your own risk.\n\n# MineTrain\n[![GitHub release](https://img.shields.io/github/release/SteffanPerry/MineTrain.svg)](https://github.com/SteffanPerry/MineTrain/releases)\n\n\nA lightweight and easy to use shard for running crystal in AWS Lambda\n\nMineTrain was heavily influenced by the following projects:\n  - https://github.com/spinscale/crystal-aws-lambda\n  - https://github.com/lambci/crambda\n\n## Installation\nAdd MineTrain to your crystal functions `shards.yml` file\n\n```\ndependencies:\n  mine_train:\n    github: SteffanPerry/MineTrain\n    version: 0.0.2\n```\n\n## Usage\nCreate a method that optionally accepts the mine train event and context types:\n\n```\nrequire \"mine_train\"\n\nclass CustomClass\n  def self.perform(event : MineTrain::Lambda::Event, context : MineTrain::Lambda::Context)\n    # Do work...\n  end\nend\n```\n\nIn your entry file, require `mine_train` and pass a block to the `mine_train_run` method:\n\n```\nrequire \"mine_train\"\nrequire \"./custom_class.cr\"\n\nmine_train_run do |event, context|\n  CustomClass.perform(event, context)\nend\n```\n\nYou can use use event values within the `mine_train_run` block to dynamically call specific jobs based on input. Additionally, methods do not need to accept event or context arguments if they are not required.\n\n```\n# custom_class.cr\nrequire \"mine_train\"\n\nclass CustomClass\n  def self.perform(event : MineTrain::Lambda::Event, context : MineTrain::Lambda::Context)\n    # Do work...\n  end\n\n  def self.perform_two(event : MineTrain::Lambda::Event)\n    # Do work...\n  end\n\n  def self.perform_three\n    # Do work...\n  end\nend\n```\n\n```\n# main.cr\nrequire \"mine_train\"\nrequire \"./custom_class.cr\"\n\nmine_train_run do |event, context|\n  case event.body[\"value\"]\n  when \"perform\"\n    CustomClass.perform(event, context)\n  when \"perform_two\"\n    CustomClass.perform_two(event)\n  when \"perform_three\"\n    CustomClass.perform_three\n  end\nend\n```\n\n## Building and deployment\nTaken from another project, use docker to build the bootstrap and upload the zipped file to your aws lambda function:\n\nBuild the application\n```\ndocker run --rm -it -v $PWD:/app -w /app crystallang/crystal:latest \\\n  crystal build src/main.cr -o lib/mine_train/bootstrap/bootstrap \\\n    --release --static --no-debug\n```\n\nZip the deployable bootstrap\n```\nzip -j bootstrap.zip lib/mine_train/bootstrap/bootstrap\n```\n\n## MineTrain::Lambda::Event\nThe `MineTrain::Lambda::Event` type has two public methods:\n\n### body\nthis is the JSON parsed value of the raw event.body\n\n### raw\nThis is the raw event request from the lambda invocation\n\n## MineTrain::Lambda::Context\nThe `MineTrain::Lambda::Context` type has the following public methods:\n\n### function_name\nThe name of the lambda function\n\n### function_version\nThe version of the lambda function\n\n### memory_limit_in_mb\nThe configured memory for the lambda function\n\n### log_group_name\nThe lambda functions log group\n\n### log_stream_name\nThe log stream for the lambda function\n\n### aws_request_id\nThe unique AWS request ID\n\n### invoked_function_arn\nThe ARN of the invoked function\n\n### deadline_ms\nThe remaining time in mills to complete the lambda function\n\n### identity (optional)\nThe cognito invocation identity\n\n### client_context (optional)\nThe client context of the lambda function\n\n### get_remaining_time_in_millis\nMethod which returns the remaining time to complete the function\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsteffanperry%2Fminetrain","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsteffanperry%2Fminetrain","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsteffanperry%2Fminetrain/lists"}