would like to know if CheckUpkeep() in the Chainlink Keeper interface can be invoked externally? - chainlink

My objective is to call checkUpkeep() externally to update checkData with data offchain and then have the same passed onchain via performData and performUpkeep()
Thanks

Yes, checkUpKeep can be set to the external access modifier.
Reference: Chainlink Docs

Related

AWS API Gateway Routing

How can route a request from API Gateway based towards the lambda functions A/B/C based in the fact that specific header is present or not?
https://api.example.com/prod
if the headers "UserType" is:
guest -> redirect to lambda A
normal -> redirect to lambda B
admin -> redirect to lambda C
I know how only using different URL, e.g:
https://api.example.com/prod
https://api.example.com/dev
It's actually not possible. We can bind only one Lambda function with a specific resource of API Gateway. The headers are accessible as an event parameter within the lambda function itself.
Preferred way would be to create 3 different functions(your business logic's will reside here) within your lambda & based on usertype you can call the function.
And if you really want to make use of three different lambdas, you can make use of invoke method available in aws-sdk. You can refer following link for code syntax & example.
https://docs.aws.amazon.com/AWSJavaScriptSDK/latest/AWS/Lambda.html#invoke-property
2nd method will definitely increase the response time.

Does the value of global variable persist in multiple API calls

So I have done a lot of research and could not find a proper answer. This might be a bit long post so sorry for that. I am making a backend API using golang. I am using gingonic for routing and api stuffs.
There are 2 part of the service. Application and user. When lets say createAccount endpoint is called from the other micro service, it need to pass the user information and application token in body. Each application is like micro service that is registered to this micro service that I am building and have a unique token. If the token they pass matches then I will get the id of that row and use that to create an entry in user table which will have the id associate with it.
Now for every API call to this micro service, it is important that they are sending the valid token and that row id is needed to do all sort of functionality like login user, edit user info and so on as the each user is connected with that app id by foreign key. Currently, I wrote a middleware and when any api call is made I get row id and save it to a global variable and then when necessary I am using it in any part of the codebase.
Lets say if 5 multiple API call is made, will that global variable information will be persisted or for each call its brand new value? If it is persisted then what can I do to achieve the brand new of Global variable for every API call or if there are better approach can you please recommend it?
A global variable is not the answer here. It will be overwritten by each request as you suspected. Instead, the typical way to handle this situation is to have a context object that is created within the scope of the HTTP Request and passed to each method that requires knowledge of that context.
One basic rule is to AVOID using the global variables, it is bad practices, you cannot manage the state and you are limited for testing and concurrency using.
In my mind come two basic solutions:
Use context for this. In your handler, add the value in context and propagate this context by all your service calls. It is also useful for tracing if you are working with microservices, then you also should take a look for this. And in the place where you need the value from your global variable, do simple call: ctx.Value(YOUR_KEY) Take a look at the end of the page, you shouldn't use string as the key to context values.
You can wrap your data in the struct with this variable value. For example:
type CreateReq struct {
Token string // value from global variable
User user
}
and use this Token in your services.

Is it possible to pass an API Gateway variable into a Lambda Context?

I'd quite like to be able to use context.stage in a Lambda call, passed in from the API gateway context - but I can only see how to put it into the message body (event object).
Is there any way to add arbitrary information to the Lambda Context?
I believe your only option is to add it to the event. You can always extract the value at the start of your Lambda function and then delete the property.
The Rest API example from AWS does something similar:
var operation = event.operation;
delete event.operation;

Does Parse.Cloud.beforeRead exist is some form?

In Parse there is something called:
Parse.Cloud.beforeSave
I wonder if there is something to play the role of a:
Parse.Cloud.beforeRead
I need a way to control what is going to be returned to the user when a request is made to the DB.
In particular in certain circomstances, depending on information on the server, I want to force blank fields in the result of the DB request made by the user. Any standard way to do this?
There is no Parse.Cloud.beforeRead kind of function supported by Parse.
Instead, you can define a custom cloud function using
Parse.Cloud.define('readObjects', function(request, response) {...} );
that returns array of objects. This function will act as a wrapper over the Parse query.
Then, your client apps should be calling this cloud function to fetch objects rather than direct Parse.Query requests.

How can I limit access to specific functions in CodeIgniter?

I have a huge controller in codeigniter, with many functions. I want to limit access to certain functions. How should I proceed?
And can I call the functions using cron daemon???
Or should I place those functions in another controller??
a) To limit the access to functions in your controller you shold use private function declaration example:
function _example_function() {...} USING the underscore!!
This way its impossible to call this function by URL.
b) Other simple way to restrict the access to functions in your controller is to use session variables and states to block the access.
2.) Yes you can use cron to run function just call the URL:
http://host/controller_name/FUNCTION
Regards,
Pedro
I have a huge controller in
codeigniter, with many functions. I
want to limit access to certain
functions. How should I proceed?
You can use some access control based on session to limit access to certain controllers->functions only. At the start of the function you can place the code like if($_SESSION['user'] != 'xyz') exit('access denied') ;
And can I call the functions using
cron daemon???
yes you can call any controller function in cron with this command
wget https://www.example.com/controller-name/function-name
Or should I place those functions in another controller??
Its always a good idea to refactor the code if its getting very big and getting unmanageable.
Another way is to use the protected namespace. When I try calling a function which is marked as protected I'm able to use it within the PHP code yet when trying to load it trough the browser I receive a 404.
Of course marking it as private would work too, but then you'd loose the ability to use the function within an extension of your class. When working with core extensions a lot that would be a problem.
cu
Roman

Resources