Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

The file reader is very simple example of component to read in files. If you have not done so already please have a read of A brief history of Iguana The problem with no-code solutions to understand the design philosophy here. This is simple starting component to customize to what you really need.

Expand
titleThe configuration interface
Image Removed

There are three parameters:

  • The source directory which reader will poll looking for files in it.

  • A matching expression which matches the files to consume

  • How frequently to poll the directory - in seconds

Expand
titleHow does it behave?

The component behaves very simply. After a file is read and consumed by pushing the contents into a queue it is deleted.

The component logs this activity to the logs.

It’s not really intended to be all things to everyone. It is however a very simple starting point to open up and customize to what you really need.

You can see the source code for it right
Expand
titleIt does not do what I want to do!

There is only one field to configure - the SourceDir. This is the directory that the component feeds from.

Image Added
Expand
titleWhat! That's not very configurable!

No lol - it’s not is it?

In the first version of this component we did have more configuration fields on it. But taking a step back and thinking from an operations perspective it seemed like the most important field was the source directory.

If I am an operations person, then this is what I need to look at if there is a problem. Everything else just seemed like noise.

You can always change that: Custom Fields

Expand
titleWhat files does it match?

The file matching logic is deliberately isolated in it’s own file which we can see here:

https://bitbucket.org/interfaceware/fromfile/src/main/MatchRules.lua

Why do we put this logic in it’s own file? It’s applying a concept call Separation of Concerns. We simplify code and make it easy to understand by separating it into its own file.

Looking the code you can see that this code will only match files with the extensions hl7, log and txt. You can see the code in action here:

Image Added

If you need to change it then you have a very simple obvious place to go.

Expand
titleHow does it process the files?

The processing file logic is very straightforward, the source is here:

https://bitbucket.org/interfaceware/fromfile/src/main/main.luaIt’s deliberately simple to make the code non intimidating to alter and customizeProcessFile.lua

Code Block
function ProcessFile(FileName)
   local Out = FILread(FileName)
   iguana.log("Read "..FileName.." ("..#Out.." bytes)");
   queue.push{data=Out}
   LastFile = FileName
   if component.live() then os.remove(FileName) end                           
end

It inhales the file, queues the contents and deletes it.

If you want to do something different or more complex - you absolutely can.

Expand
titleI don't like that you can change components so easily!

You do not have to use the components we supply in production.

In fact if you are a large company I would not recommend it. It would make more sense to start with the components we give you. Customize them the way that works for your organization and make your own official git collections.

That makes a lot more sense in terms of giving you the control and standardization needed for large organizations.

Expand
titleArgh I need help !!

Reach out! Lets talk about what you need to do.

We are here to help.

We are genuinely interested in getting a real understanding of the kinds of problems that customers need to solve.There

We are a variety of ways we might help you.

  • It could be by improving our educational resources around using Lua.

  • Perhaps there is a real repeatable need which may make it sensible to build a new component

looking ways to make our customer’s lives easier, whether that’s through better documentation, examples or just a little friendly encouragement.

In the long run we expect larger customers operating at scale will probably find it benefits them to curate their own ‘standard’ component set.
Expand
titleHow does this work out in the long run?

These are components which mean their typical needs based on the needs of their organization.

We also expect there will be areas where we develop new components that fit well defined common use cases. Cases that meet the needs of thousands of interfaces.

In other cases it will be about helping large companies build components which are ultra well suited to them.

Hope that helps and do free to reach out and talk with us.