# Making a struct definition available on the cluster

**URL:** <https://discourse.julialang.org/t/making-a-struct-definition-available-on-the-cluster/17460>\
**Category:** Julia at Scale\
**Tags:** question\
**Created:** [November 13, 2018, 2:52am UTC](https://discourse.julialang.org/t/making-a-struct-definition-available-on-the-cluster/17460 "2018-11-13T02:52:02Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![rabarar](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/rabarar/32/6002_2.png) [@rabarar](https://discourse.julialang.org/u/rabarar)\
**Post date:** [November 13, 2018, 2:52am UTC](https://discourse.julialang.org/t/making-a-struct-definition-available-on-the-cluster/17460/1 "2018-11-13T02:52:02Z")

</div>

So I’m new to Julia - and I’ve been experimenting with the Distributed package - I wrote an example program to illustrate some of the concepts. Using remote channels, I can create primitive remote channel type, but how can I create a user-defined Remote Channel Type? For example, if I define a simple struct:

struct Ctrl  
n::Int64  
q::Bool  
end

How can I make a remote Channel of type Channel{Ctrl}. When I attempt to do so, the struct reference isn’t defined in the worker procs.

---

<div class="post-metadata">

**Author:** ![baggepinnen](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/baggepinnen/32/693_2.png) [@baggepinnen](https://discourse.julialang.org/u/baggepinnen)\
**Post date:** [November 13, 2018, 7:11am UTC](https://discourse.julialang.org/t/making-a-struct-definition-available-on-the-cluster/17460/2 "2018-11-13T07:11:26Z")

</div>

Define the struct everywhere according to

```julia
@everywhere struct Ctrl
    n::Int64
    q::Bool
end

```

This defines the struct on all workers that are running while the struct is defined, so start your workers before defining the struct like above.

PS: also, don’t forget to [quote your code](https://discourse.julialang.org/t/psa-how-to-quote-code-with-backticks/7530)

---

<div class="post-metadata">

**Author:** ![rabarar](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/rabarar/32/6002_2.png) [@rabarar](https://discourse.julialang.org/u/rabarar)\
**Post date:** [November 13, 2018, 6:25pm UTC](https://discourse.julialang.org/t/making-a-struct-definition-available-on-the-cluster/17460/3 "2018-11-13T18:25:13Z")

</div>

Thanks - I failed to realize that `@everywhere` was not a directive and rather required to be issued _after_ the workers were created - duh!

Here’s the repo of the code if anyone’s interested:

> <https://github.com/rabarar/juliaSnippets/blob/master/distributed/eg1.jl>
