Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add document that explains the new policies system #512

Merged
merged 1 commit into from
Nov 30, 2017
Merged

Conversation

davidor
Copy link
Contributor

@davidor davidor commented Nov 29, 2017

Closes #509

/cc @3scale/documentation

@davidor davidor requested a review from mikz November 29, 2017 14:43
@davidor davidor force-pushed the policies-doc branch 2 times, most recently from 7497017 to ce0cdec Compare November 29, 2017 15:13
@mikz
Copy link
Contributor

mikz commented Nov 29, 2017

@nmasse-itix this might be interesting to you, review/suggestion much welcomed

`init_worker`, `rewrite`, `access`, `balancer`, `header_filter`, `body_filter`,
`post_action`, and `log`.

Policies can share data between them. They do that through what we call the

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe say "share data between phases" to be even more explicit (or people could understand sharing between policies)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Both things are possible.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To clarify, whatever you write in the context will be available in later phases of the same policy and in other policies as well. Do you think that's clear in the document?

that describes what to run in `access` and `header_filter`. Assume also that
when describing the chain, we indicate that policy A should be run before
policy B. When APIcast receives a request, it will check the policy chain
described to see what it should run on each phase:

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what would the term/name to use here? "policy chain definition" (sustantivo)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure what you mean here @andrewdavidmackenzie

doc/policies.md Outdated
when describing the chain, we indicate that policy A should be run before
policy B. When APIcast receives a request, it will check the policy chain
described to see what it should run on each phase:
- rewrite: execute what policy A specifies for this phase.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"execute the method/function policy A provides for this phase" or similar?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

- post_action: do nothing. Neither policy A nor B describe what to do.
- log: do nothing. Neither policy A nor B describe what to do.

Notice that we did not indicate what APIcast does in the `init` and the

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of describing "in the negative", explain this as part of APIcast start-up before this, then move onto the description of handling requests?

for a given service. This means that we can apply different policies to our
services, or the same policies but configured differently, or in a different
order. On the other hand, there's only one global chain, and the behavior it
defines applies to all the services.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

so, policies defined by both chains will be run?
How is order defined between policies in the global chain and policies in the service chain....

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, per-service are included as part of the global one.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The order of policies in the global chain is configurable. The order of policies in per-service chains is also configurable.

doc/policies.md Outdated
[Policy](../gateway/src/apicast/policy.lua) and defines a method for each of
the phases where it needs to execute something.

Suppose that we wanted to run a policy that logged some message in the

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"logged a message"

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

doc/policies.md Outdated
-- Read something from the context.
local smth = context.something

-- Write 'b' in the context so other policies or later phases can read it.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"into" maybe...

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

local _M = policy.new('My custom policy')
local new = _M.new

function _M.new(config)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe explain when new() is called?
How to store values from the config it receives for use in the per-request methods later?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think that documenting when it's instantiated it's too much detail for this document.
Your second question is exactly what I wanted to show with this example. See self.option_a and self.option_b below.

```

In the [policy folder](../gateway/src/apicast/policy) you can find several
policies. These ones are quite simple and can be used as examples to write your

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"They are quite..."

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think that's correct, because I'm not listing all of them, just some examples.

doc/policies.md Outdated

## Integrate your policies

At some point, it will be possible to configure policies through the 3scale UI,

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"configure policies and policy chains" ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

doc/policies.md Outdated
## Integrate your policies

At some point, it will be possible to configure policies through the 3scale UI,
but you can also integrate them in APIcast using a configuration file. Remember

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

use the same verb: "configure"?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

doc/policies.md Outdated
Here's an example that shows how to define a policy chain with the CORS policy
and the APIcast one. Please note that the configuration of services is more
complex than shown here. This is a very simplified version to illustrate how
policies can be integrated:

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"configured"?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

doc/policies.md Outdated
}
```

If instead of configuring the policy chain of a specific service, you need to

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"you want to"...

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

doc/policies.md Outdated

If instead of configuring the policy chain of a specific service, you need to
customize the global policy chain, you can take a look at
[this example](../examples/policy_chain/README.md).

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good job David and Michal! We're on our way to vast improvements......

@davidor
Copy link
Contributor Author

davidor commented Nov 29, 2017

Thanks for the review @andrewdavidmackenzie . I addressed all your comments.

Copy link
Contributor

@mikz mikz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Love it! 🥇

I think it nails the level of detail to be usable but not to dive into too technical details to be overwhelming.

@davidor davidor merged commit 3e05a6a into master Nov 30, 2017
@davidor davidor deleted the policies-doc branch November 30, 2017 09:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants