Hello,
I am writing my own plugin and when testing it is not showing any example
in the code i will this text as BOLD as i am sending the .rb in the spec and lib directory
[root@Daley-DB-second inputs]# bundle exec rspec
Your RubyGems version (2.7.10) has a bug that prevents `required_ruby_version` from working for Bundler. Any scripts that use `gem install bundler` will break as soon as Bundler drops support for your Ruby version. Please upgrade RubyGems to avoid future breakage and silence this warning by running `gem update --system 3.2.3`
**No examples found.**
**Finished in 0.03394 seconds (files took 0.50193 seconds to load)**
**0 examples, 0 failures**
[root@Daley-DB-second inputs]# more example_spec.rb
# encoding: utf-8
require "logstash/devutils/rspec/spec_helper"
require "logstash/devutils/rspec/shared_examples"
require "logstash/inputs/example"
describe LogStash::Inputs::Example do
it_behaves_like "an interruptible input plugin" do
let(:config) { { "interval" => 100 } }
end
end
# encoding: utf-8
require "logstash/inputs/base"
require "logstash/namespace"
require "stud/interval"
require "socket" # for Socket.gethostname
# Generate a repeating message.
#
# This plugin is intented only as an example.
class LogStash::Inputs::Grpc < LogStash::Inputs::Base
config_name "grpc"
# If undefined, Logstash will complain, even if codec is unused.
default :codec, "plain"
# The message string to use in the event.
config :message, :validate => :string, :default => "Hello World!"
# Set how frequently messages should be sent.
#
# The default, `1`, means send a message every second.
#config :interval, :validate => :number, :default => 1
config :host, :validate => :string, :default => "0.0.0.0"
public
def register
@host = Socket.gethostname
end # def register
def run(queue)
# we can abort the loop if stop? becomes true
while !stop?
event = LogStash::Event.new("message" => @message, "host" => @host)
decorate(event)
queue << event
# because the sleep interval can be big, when shutdown happens
# we want to be able to abort the sleep
# Stud.stoppable_sleep will frequently evaluate the given block
# and abort the sleep(@interval) if the return value is true
Stud.stoppable_sleep(@interval) { stop? }
end # loop
end # def run
def stop
# nothing to do in this case so it is not necessary to define stop
# examples of common "stop" tasks:
# * close sockets (unblocking blocking reads/accepts)
# * cleanup temporary files
# * terminate spawned threads
end
end # class LogStash::Inputs::Grpc