That's like being a soldier until a war comes along, then you're suddenly a pacifist.
I don't know what the rules are today but, when I was in the Army it was possible to be in uniform and be a pacifist. There were non-combat roles to which such people were assigned.
In my case, the government changed the rules on me. When I was first appointed as a JP I asked specifically about same sex "marriages," and I was assured that I was not required to perform such ceremonies. Those were the terms under which I accepted the commission. Now I'm being told that "technically" I AM required to perform them if asked, but if I don't want to do it I can just say I'm not available. Except that wouldn't be true, so if the situation arises I will resign. If the situation doesn't arise, I see no need to resign.
The JP situation is parallel to the country clerk in that both are civil, not religious, public offices. The difference is that each county only has one county clerk, and that's the only office in that county that can issue marriage licenses. In my state, any JP in the state can perform a marriage in any town or city in the state. The town I live in (where I was appointed) is under 10,000 people, and has something like 50 JPs (20 Democrats, 20 Republicans, and 10 -- or so -- unaffiliated voters). So it's not as though my declining to perform a same sex "marriage" is going to make it impossible for a couple to have their ceremony.
Unlike most JPs in my state, I didn't accept the appointment so I can perform marriages. I accepted it because it authorizes me to perform certain other official acts, such as certifying signatures on documents and taking depositions. I feel no compunction to give that up over a situation that's unlikely to arise.