Skip to content

bernardbaker/ruby.time.zone.converter.microservice

Repository files navigation

Ruby Time Zone Converter Microservice

gRPC microservice that converts a timestamp into a target IANA timezone, matching the Java implementation.

Prerequisites

  • Ruby 3.2+ (3.3.7 recommended; see .ruby-version)
  • Bundler (gem install bundler)
  • grpcurl for manual calls and load tests (brew install grpcurl)

Install Ruby on macOS

System Ruby (2.6) is too old. Use Homebrew or rbenv:

# Option A — Homebrew
brew install ruby
export PATH="/usr/local/opt/ruby/bin:$PATH"   # Intel
# export PATH="/opt/homebrew/opt/ruby/bin:$PATH"  # Apple Silicon

# Option B — rbenv
brew install rbenv ruby-build
rbenv install 3.3.7
rbenv global 3.3.7

Quick start

gem install bundler
bundle install
bundle exec rake test    # generates proto stubs, runs RSpec
bundle exec rake server  # or: bundle exec ruby -I lib lib/server.rb

Server listens on port 8080 by default (PORT env overrides).

Manual request

./curl.sh

Load testing

Start the server, then in another terminal:

# Light smoke
DURATION_SECONDS=30 CONCURRENCY=8 ./simulate_traffic.sh

# Run on another port when Node/Java use 8080
PORT=8081 bundle exec rake server
HOST=localhost:8081 DURATION_SECONDS=10 CONCURRENCY=4 ./simulate_traffic.sh

API

Item Value
Service timezone.TimeZoneConverter
Method ConvertTime
Port 8080 (plaintext gRPC)

Golden example: 2024-12-04T15:00:00Z + America/New_York2024-12-04T10:00:00-05:00

Project layout

  • proto/api.proto — gRPC contract
  • lib/time_converter.rb — conversion logic (TZInfo)
  • lib/time_zone_converter_service.rb — RPC handler
  • lib/server.rb — server entrypoint
  • lib/timezone/proto/ — generated protobuf/gRPC stubs (rake proto)

Rake tasks

Task Description
rake proto Generate Ruby stubs from proto/api.proto
rake test Proto gen + RSpec
rake server Start gRPC server

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors