frugal icon indicating copy to clipboard operation
frugal copied to clipboard

Sample code on readme does not compile

Open myles-mcdonnell opened this issue 3 years ago • 1 comments

Seems that frugal.NewFNatsScopeTransportFactory as referenced on the root README does not exist anymore.

I'll raise a PR with the fix once I have worked it out but currently stuck at what thrift go package version I need to compile the gen code.

myles-mcdonnell avatar Feb 14 '21 11:02 myles-mcdonnell

I have resolved this by instantiating both a FNatsSubscriberTransportFactory and a FNatsPublisherTransportFactory but I haven't raised a PR as this seems wrong to create both pub and sub transport factories in the pub and sub? Maybe not though as it does that in the example code?

var (
   protocolFactory            = frugal.NewFProtocolFactory(thrift.NewTBinaryProtocolFactoryDefault())
   subscriberTransportFactory = frugal.NewFNatsSubscriberTransportFactory(conn)
   publisherTransportFactory  = frugal.NewFNatsPublisherTransportFactory(conn)
   provider  = frugal.NewFScopeProvider(
			publisherTransportFactory,
			subscriberTransportFactory,
			protocolFactory)
   subscriber = event.NewEventsSubscriber(provider)
)

Also the function signature for SubscribeEventCreated now takes frugal.FContext not a pointer to that type:

_, err = subscriber.SubscribeEventCreated(func(ctx frugal.FContext, e *event.Event) {
   fmt.Println("Received event:", e.Message)
})

Hope this is helpful in some way.

myles-mcdonnell avatar Feb 14 '21 15:02 myles-mcdonnell